Thanks Richard, but we call rollback only when my earlier sqlite3_step has 
failed for some reason. Can it still undo some inserts/updates/deletes from a 
previously executed but not yet commited tx ?

Does completion of sqlite3_step with success , means a transaction was 
successfully commited ?

Are there other scenarios where , even though I am calling rollback when 
sqlite3_step returns failed, it can undo previous txs.

-mayank


-----Original Message-----
From: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Richard Hipp
Sent: Monday, March 09, 2015 3:27 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] sqlite3_exec ROLLBACK command

On 3/9/15, Mayank Kumar (mayankum) <mayankum at cisco.com> wrote:
> Hi All
>
> We have some legacy code which calls sqlite3_exec with ROLLBACk every 
> time sqlite3_step fails irrespective what specific error occurred. I 
> am wondering if this is a safe behavior or should I change this.  Can 
> it cause any sideeffects or memory leak or any other issues ?

ROLLBACK is always "safe" in the sense that it preserves the database in an 
intact and consistent form.  The only downside is that it might undo some 
INSERTs, UPDATEs, or DELETEs that you have previously executed but not yet 
committed.  If you don't mind losing all the changes that have occurred since 
the start of the transaction, then it is always safe to do ROLLBACK.


--
D. Richard Hipp
drh at sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to