txn-insert-only.html 823 B

12345678910111213141516171819202122232425
  1. An **insert-only** transaction only contains [`INSERT`] statements that insert
  2. into the **same** table.
  3. On a successful [`COMMIT`], all statements from the transaction are committed at
  4. the same timestamp.
  5. ```mzsql
  6. BEGIN;
  7. INSERT INTO orders VALUES (11,current_timestamp,'brownie',10);
  8. -- Subsequent INSERTs must write to sales_items table only
  9. -- Otherwise, the COMMIT will error and roll back the transaction.
  10. INSERT INTO orders VALUES (11,current_timestamp,'chocolate cake',1);
  11. INSERT INTO orders VALUES (11,current_timestamp,'chocolate chip cookie',20);
  12. COMMIT;
  13. ```
  14. If, within the transaction, a statement inserts into a table different from that
  15. of the first statement, on [`COMMIT`], the transaction encounters an **internal
  16. ERROR** and rolls back:
  17. ```none
  18. ERROR: internal error, wrong set of locks acquired
  19. ```