@@ -284,13 +284,22 @@ bool DBBrowserDB::setSavepoint(const QString& pointname)
284284
285285bool DBBrowserDB::releaseSavepoint (const QString& pointname)
286286{
287- if (!isOpen () || savepointList. contains (pointname) == false )
287+ if (!isOpen ())
288288 return false ;
289+ if (savepointList.contains (pointname) == false )
290+ // If there is no such savepoint in the list,
291+ // we have already released it, so in this case
292+ // the operation should be successfull
293+ return true ;
289294
290295 QString query = QString (" RELEASE %1;" ).arg (pointname);
291296 if (!executeSQL (query, false , false ))
292297 return false ;
293- savepointList.removeAll (pointname);
298+ // SQLite releases all savepoints that were created between
299+ // creation of given savepoint and releasing of it,
300+ // so we should too
301+ int point_index = savepointList.lastIndexOf (pointname);
302+ savepointList.erase (savepointList.begin ()+point_index, savepointList.end ());
294303 emit dbChanged (getDirty ());
295304
296305 return true ;
@@ -305,7 +314,11 @@ bool DBBrowserDB::revertToSavepoint(const QString& pointname)
305314 executeSQL (query, false , false );
306315 query = QString (" RELEASE %1;" ).arg (pointname);
307316 executeSQL (query, false , false );
308- savepointList.removeAll (pointname);
317+ // SQLite releases all savepoints that were created between
318+ // creation of given savepoint and releasing of it,
319+ // so we should too
320+ int point_index = savepointList.lastIndexOf (pointname);
321+ savepointList.erase (savepointList.begin ()+point_index, savepointList.end ());
309322 emit dbChanged (getDirty ());
310323
311324 return true ;
0 commit comments