I am trying to migrate to MySQL/Percona server 8.0 and GTID based replication and have stumbled upon the issue where CREATE TABLE AS SELECT is not allowed using GTID.
The tables that are created are for materializing complex selects which span several tables and can not be replaced by a simple CREATE TABLE LIKE.
Since these are slow and complex selects they already use the CREATE TABLE AS SELECT LIMIT 0 + INSERT INTO SELECT pattern to get around the metadata lock issues. This in my mind should mean that the code I am using already is replication safe with GTIDs, but all CREATE TABLE AS SELECT are blocked when using enforce-gtid-consistency (even though https://www.percona.com/blog/2018/01/10/why-avoid-create-table-as-select-statement/ suggests otherwise), so I need a workaround.
I have already found that replacing the CREATE TABLE AS with a CREATE TEMPORARY TABLE AS together with a CREATE TABLE LIKE may get around the problem, but it seems like a ugly hack to me so I wonder if there is any better way of getting around the issue?