Add mysqli_rollback_to
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
In PHP 5.5 mysqli::savepoint and mysqli::release_savepoint were added, but not rollback_to. Maybe there is some database engine where savepoints have multiple purposes, but in mariadb the only use of savepoints is to call query ROLLBACK TO name manually.
For completion: existing rollback with $name is doing nothing (only adding comment) at least in mariadb/mysql.
Method signature
class mysqli { /* ... */
public function rollback_to(string $name) : bool;
}
Sample test sequence
mysqli_query($link, 'DROP TABLE IF EXISTS test');
mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB');
mysqli_begin_transaction($link);
mysqli_query($link, 'INSERT INTO test(id) VALUES (1)');
mysqli_savepoint($link, 'foo');
mysqli_query($link, 'INSERT INTO test(id) VALUES (2)');
mysqli_rollback_to($link, 'foo');
mysqli_commit($link);
$res = mysqli_query($link, "SELECT * FROM test");
var_dump($res->num_rows); // int(1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing mysqli::savepoint, mysqli::release_savepoint, and mysqli::rollback entry points and their related tests. Use the sample transaction sequence as the behavioral check: rolling back to the savepoint should remove the second insert while preserving the first after commit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, mariadb, mysql, php
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100