Re: [Proposal] Add `savepoint()` method to PDO

From: Date: Mon, 05 Feb 2024 16:29:54 +0000
Subject: Re: [Proposal] Add `savepoint()` method to PDO
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-122286@lists.php.net to get a copy of this message
On Mon, Feb 5, 2024, at 1:54 PM, Saki Takamachi wrote: > Hi Kentaro, > > Thank you for your important point. > >> While most databases use SAVEPOINT [name], but: >> >> >> https://github.com/laravel/framework/blob/v10.43.0/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php#L453-L456 >> >> ```php >> return 'SAVE TRANSACTION '.$name; >> ``` >> >> SQL Server uniquely uses SAVE TRANSACTION [name]. There >> might be >> other variations in databases, so full support could be challenging, >> which is something to be mindful of. > > I think this feature will be implemented for each driver, so it > probably won't be a problem for anything other than pdo_odbc. As you > say, I think I need to think a little more about pdo_odbc. > > (When I looked into odbc3 again, I realized that what I had written was > not an API for odbc, sorry. Therefore, it may be difficult to support > this feature stably with ODBC.) > > I'll see if there's a better way. > >>> change the signature of rollback() to >>> rollback(?string $name = null). >> >> This might lead to confusion due to rollback() having >> multiple >> functionalities, as ROLLBACK and ROLLBACK >> TO [name] target >> different rollback operations. >> >> Just as beginTransaction() and >> savepoint() are separate, perhaps >> having a separate method for rolling back to a savepoint might >> maintain consistency, for example rollbackToSavepoint(string >> $name). > > Regarding this, mysqli's rollback() is such a > specification, so I > used that as a reference. However, it may be safer to separate the > method itself. > > rollbackTo() might also be good. I like this proposal. It's a good incremental improvement to PDO. I also agree with rollbackTo(), to avoid confusion. --Larry Garfield

« previous php.internals (#122286) next »