https://dev.mysql.com/doc/refman/8.0/en/commit.html
If a SELECT statement within a transaction calls a stored function, and a statement within the stored function fails, that statement rolls back. If ROLLBACK is executed for the transaction subsequently, the entire transaction rolls back.
Could you give me an example of that part of the documentation?
From my understanding if the stored function fails the whole transaction will fail, not just the SELECT a_stored_function();
I am confused, is there an error in the documentation?
This deliberately causes an error in the function, by trying to stuff an 8-character string into a local variable that is
varchar(3). It's too long, so it causes an error when we call the function with that argument:Does this roll back the
INSERTdone during the same transaction? The proof would be when weSELECTafter committing the transaction.Result:
The
INSERTwas not rolled back. Only the single statement that called the function with the error was rolled back ("rolling back" aSELECThas no observable effect).P.S.: This kind of quick proof of concept test is something you should be able to do yourself as a programmer. I think that's what the comments from RiggsFolly above were getting at.