Relation:transaction

Combines all instructions in the block as one atomic instruction. The write instruction only write permanently if no assert instruction returns false.

Description

transaction

instructionlist

end transaction

Parameters

instructionlist: any instruction except function and include.

Examples

transaction
read "films.csv"
insert "Home", "Meier", 2007
assert unique film
write "films.csv"
end transaction

film director year
A bout de souffle Godard 1960
Tirez sur le pianiste Truffaut 1960
Home Meier 2007

Comments

With the transaction instruction, Belle Nuit Relation becomes more ACID-compliant. The transaction is Atomic, Consistent and Durable. Only the isolation part of ACID is missing: Several Relation documents may write concurrently to the same folder and other applications might write to the folder as they are exposed to the file system.

The order between write and assert does not matter. If you read from previously written files, it will use the written temporary files.

Implementation: Inside the block, files are written to a temporary file. If there are no assertions or all assertions are true, at the end of the block the temporary file is moved to the persistant file. If there is at least one assertion error, the temporary file is deleted.