The MariaDB INSERT IGNORE... SELECT
syntax is defined at https://mariadb.com/kb/en/insert/.
I am also relying on the assumption that each INSERT
in this situation will be performed in the order of the SELECT
clause result set.
Test case:
DROP TEMPORARY TABLE IF EXISTS index_and_color;
CREATE TEMPORARY TABLE index_and_color (`index` INT PRIMARY KEY, color TEXT);
INSERT IGNORE INTO index_and_color SELECT 5, "Red" UNION ALL SELECT 5, "Blue";
SELECT * FROM index_and_color;
Intuitively, I see that the "first" row in the SELECT
clause result set has (5, "Red")
and then the "second" row is ignored, containing the same key with "Blue".
From what I see, this is undefined behavior because another server implementing the same documentation could handle the rows in a different order.
Is my usage here indeed relying on undefined behavior?