MySQL cascaded foreign keys do not activate triggers
Config Back end relies on triggers to create audit entries (among many other things). However, we were not aware that MySQL has the following caveat:
Cascaded foreign keys do not activate triggers.
(https://dev.mysql.com/doc/refman/8.0/en/create-trigger.html)
This breaks at least one use case:
When a shared network is deleted all subnets which belonged to it must have their shared network name column set to null. An audit entry will be created for the shared network via the ADEL trigger on dhcpX_shared_network table, however no audit entries will be made for the subnets as these entries are expected to be created by the AUPD trigger on the dhcpX_subnet table because those updates are triggered the following foreign key constraint:
CONSTRAINT fk_dhcpX_subnet_shared_network FOREIGN KEY (shared_network_name)
REFERENCES dhcpX_shared_network (name)
ON DELETE SET NULL ON UPDATE NO ACTION
While the following unit test currently passes:
MySqlConfigBackendDHCPv4Test.getAllSharedNetworks4Test
In reality it should not. It should fail when checking audit entries after deleting networks which contain subnets.