1 / 12

Transactions - generalities

Transactions - generalities. 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’. Example extension. Transaction. logical unit of work sequence of database operations

edahle
Download Presentation

Transactions - generalities

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. Example extension

  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. 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. 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. 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. 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. COMMIT and ROLLBACK points BEGIN TRANSACTION COMMIT COMMIT time transaction time idle same point as far as the DB state is concerned BEGIN TRANSACTION COMMIT ROLLBACK time transaction time idle same state of DB

  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. 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. Pointers ahead • recovery • concurrency

More Related