TRANSACTION

Syntax: 

BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [ TRANSACTION [ name ]]   

END | COMMIT | ROLLBACK [ TRANSACTION [ name ]]
	

GDBase supports transactions with rollback and atomic commit.

The optional transaction name is ignored. GDBase does not allow nested transactions.

No changes can be made to a table except within a transaction. Any command that changes the table (basically, any SQL command other than SELECT) will automatically start a transaction if one is not already in effect. Automatically started transactions are committed at the conclusion of the command.

Transactions can be started manually using the BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command. But a transaction will also roll back if the table is closed or if an error occurs and the ROLLBACK conflict resolution algorithm is specified. See the documentation on the ON CONFLICT clause for additional information about the ROLLBACK conflict resolution algorithm.

Note

  • If a TRANSFORM block was executed during the transaction and an error occured than the whole transaction will roll back unless the error occurs during parsing or in the GLOBALS block.
  • If a user break or query kill occur in a transaction then the whole transaction will roll back.

In GDBase transactions can be DEFERRED, IMMEDIATE, or EXCLUSIVE:

The COMMIT command does not actually perform a commit until all pending SQL commands finish. Thus if two or more SELECT statements are in the middle of processing and a COMMIT is executed, the commit will not actually occur until all SELECT statements finish. The connection executing the SELECT statement can not change the selected table.

An attempt to execute COMMIT might result in an error message. This indicates that another thread or process has a read lock on the table that prevents the table from being updated. When COMMIT fails in this way, the transaction remains active and the COMMIT can be retried later after the reader has had a chance to clear.