[MDEV-8451] SAVEPOINT does not set @@in_transaction Created: 2015-07-11 Updated: 2015-07-17 Resolved: 2015-07-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Affects Version/s: | 5.3.12, 5.5, 10.0, 10.1 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Federico Razzoli | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In this case, SAVEPOINT did nothing. I think that one of the following alternatives should be implemented: 1) Implicitly start a transaction, and then create the savepoint. |
| Comments |
| Comment by Federico Razzoli [ 2015-07-11 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note that 1 would be very useful for stored procedures in a reusable context. You may want to enclose a procedure in a transaction. But you don't know if the user wants to execute it as part of another transaction, or if a transaction is already active. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-07-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I couldn't find any indication in MySQL manual or MariaDB documentation whether it should be one way or another: neither about SAVEPOINT officially starting/not starting a transaction, nor about conditions when @@in_transaction is supposed to be set. However, I think semantically the complaint is valid. First, a savepoint by its nature belongs to transaction, so if it exists, it should be inside a transaction. Second, the following looks inconsistent:
If after rolling back to savepoint we are still in the transaction, we should probably be in it right after creating the savepoint. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-07-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
That said, I think the description is not quite accurate (or maybe I misunderstood your point). It's not like SAVEPOINT does nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Federico Razzoli [ 2015-07-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
True - I trusted @in_transaction, and for this reason I thought that SAVEPOINT in the example did nothing. I was wrong. But then, the bug seems to be in @in_transaction. Or, if it is not a bug, this confusing behavior should be well documented: under which conditions should I trust @in_transaction? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-07-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It looks like a bug to me, but lets see what serg says. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2015-07-17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is intentional. A <savepoint statement> is an SQL-transaction statement (See SQL Standard 2003, Part 2 Foundation, 4.33.2.4 SQL-transaction statements). Later in 4.33.4 (SQL-statements and transaction states), it is written that
In other words, SAVEPOINT should not start a transaction. |