Drizzled Public API Documentation

rollback.inc
00001 # 
00002 # We start a transaction, roll it back, and test
00003 # that the transaction has not made it to the log.
00004 #
00005 
00006 --disable_warnings
00007 DROP TABLE IF EXISTS t1;
00008 --enable_warnings
00009 
00010 SET AUTOCOMMIT= 0;
00011 
00012 CREATE TABLE t1 (
00013   id INT NOT NULL PRIMARY KEY
00014 , padding VARCHAR(200) NOT NULL
00015 );
00016 
00017 # The above is committed already since CREATE
00018 # TABLE implicitly does a commit.
00019 
00020 INSERT INTO t1 VALUES (1, "I love testing.");
00021 INSERT INTO t1 VALUES (2, "I hate testing.");
00022 
00023 # Try rolling back the above insertions...
00024 
00025 ROLLBACK;
00026 
00027 # Let's try an explicitly-started transaction as well
00028 
00029 START TRANSACTION;
00030 
00031 INSERT INTO t1 VALUES (1, "I love testing.");
00032 INSERT INTO t1 VALUES (2, "I hate testing.");
00033 
00034 ROLLBACK;
00035 
00036 START TRANSACTION;
00037 INSERT INTO t1 VALUES (1, "I love testing.");
00038 SAVEPOINT `savept1`;
00039 INSERT INTO t1 VALUES (2, "I hate testing.");
00040 ROLLBACK TO SAVEPOINT savept1;
00041 COMMIT;
00042 
00043 START TRANSACTION;
00044 SAVEPOINT `savept2`;
00045 INSERT INTO t1 VALUES (2, "I hate testing.");
00046 RELEASE SAVEPOINT `savept2`;
00047 SAVEPOINT `savept3`;
00048 INSERT INTO t1 VALUES (3, "I love testing.");
00049 SAVEPOINT `savept4`;
00050 ROLLBACK TO SAVEPOINT savept3;
00051 COMMIT;
00052 
00053 DROP TABLE t1;
00054 
00055 # The transaction log at this point should not
00056 # contain anything other than the CREATE TABLE
00057 # and the DROP TABLE.