Comments - Using Compound Statements Outside of Stored Programs
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.
This doesn't explain whether a compound statement outside an explicit transaction is treated as an atomic statement or not.
e.g. It's not clear if this can fail to return a row:
IF (EXISTS (SELECT * FROM table WHERE id=1)) THEN SELECT data FROM table WHERE id=1;ELSE SELECT 'data does not exist';END IF;
...if the EXISTS() is executed in a separate transaction to the subsequent SELECT, it might.
BEGIN NOT ATOMICkind of implies that it's not treated as an atomic statement. Other compound statements, like
IFdon't say "not atomic" explicitly, but they are also not atomic. For an atomic compound statement one has to use
BEGIN ATOMIC, which is not supported as of now.