Comments - Using Compound Statements Outside of Stored Programs

1 year, 2 months ago Dean Trower

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.

1 year, 2 months ago Sergei Golubchik

The syntax BEGIN NOT ATOMIC kind of implies that it's not treated as an atomic statement. Other compound statements, like IF don'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.

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.