Presentation is loading. Please wait.

Presentation is loading. Please wait.

Transactions generalities 1 Transactions - generalities.

Similar presentations

Presentation on theme: "Transactions generalities 1 Transactions - generalities."— Presentation transcript:

1 Transactions generalities 1 Transactions - generalities

2 Transactions generalities 2 Transactions - example Parts P_id, P_name, Colour, Weight, Total_qty Contracted S_id, P_id, Qty Update add a new contract between S4 for 200 pieces of P1

3 Transactions generalities 3 Example extension

4 Transactions generalities 4 Transaction logical unit of work sequence of database operations transforms a consistent state of a db into another consistent state between operations the db can be inconsistent

5 Transactions generalities 5 Pseudo-code BEGIN TRANSACTION; INSERT (S4, P1, 200) INTO Contracted; IF any error occurred THEN GO TO undo; UPDATE Parts WHERE P_id =P1 SET Total_qty = Total_qty + 200; IF any error occurred THEN GO TO undo; COMMIT TRANSACTION; GO TO finish; undo: ROLLBACK TRANSACTION; finish: RETURN;

6 Transactions generalities 6 SQL support COMMIT and ROLLBACK No BEGIN TRANSACTION (in SQL2 and Oracle) all data definition and data manipulation statements are transaction initiating PostgreSQL provides BEGIN [TRANSACTION]

7 Transactions generalities 7 Transaction processing do not allow for one operation to be performed and the other ones not the system should guarantee that all constituent operations will be executed not possible! hence the following principle: principle of transaction processing support if some operations are executed and then a failure occurs (before the planned termination) then those operations will be undone

8 Transactions generalities 8 Transaction manager COMMIT TRANSACTION a logical unit of work was successfully completed all the updates can be made permanent ROLLBACK TRANSACTION unsuccessful end of transaction all the attempted updates must be rolled back

9 Transactions generalities 9 COMMIT and ROLLBACK points BEGIN TRANSACTION COMMIT time COMMIT idle transaction time same point as far as the DB state is concerned BEGIN TRANSACTION ROLLBACK time COMMIT idle transaction time same state of DB

10 Transactions generalities 10 At the COMMIT point all updates, since the previous commit, are made permanent (will not be undone) all database positioning and all tuple locks are lost

11 Transactions generalities 11 ACID properties of transactions Atomicity all or nothing Consistency preserve database consistency Isolation transactions are isolated from one another Durability committed transaction updates are performed

12 Transactions generalities 12 Pointers ahead recovery concurrency

Download ppt "Transactions generalities 1 Transactions - generalities."

Similar presentations

Ads by Google