~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/transaction.test

Completes the work of removing the weirdness around transaction
boundaries in the storage engine API.

* Transactional storage engines are now all explicitly notified
  of the start of a new "normal" transaction in the new PSE API
  method plugin::TransactionalStorageEngine::doStartTransaction()
  This new method takes a start_transaction_option_t as one of its
  parameters, and passing this option allows the storage engine
  API to cleanly signal the start of a consistent snapshot (and in
  the future additional transaction attributes).  This meant the
  removal of the old start_consistent_snapshot() method.

* The TransactionServices component now fully manages the transaction
  boundaries, notification of transaction boundaries to participating
  resource managers (transactional storage engines)

Adds a simple test case (to be expanded with future XA work) for
transaction behaviour.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Tests a number of things related to transactions:
 
2
 
3
# 1. Interaction of more than one engine in a transaction
 
4
# 2. Correct commit and rollback behaviour
 
5
# 3. XA protocol communication and recovery
 
6
 
 
7
--disable_warnings
 
8
DROP TABLE IF EXISTS t1_trx, t1_non_trx;
 
9
--enable_warnings
 
10
 
 
11
SET AUTOCOMMIT= 0;
 
12
 
 
13
CREATE TABLE t1_trx (
 
14
  k VARCHAR(10) NOT NULL
 
15
, v VARCHAR(10) NOT NULL
 
16
, PRIMARY KEY (k)
 
17
) ENGINE=InnoDB;
 
18
 
 
19
CREATE TEMPORARY TABLE t1_non_trx (
 
20
  k VARCHAR(10) NOT NULL
 
21
, v VARCHAR(10) NOT NULL
 
22
, PRIMARY KEY (k)
 
23
) ENGINE=MyISAM;
 
24
 
 
25
START TRANSACTION;
 
26
 
 
27
INSERT INTO t1_trx VALUES ('key1','value1');
 
28
INSERT INTO t1_trx VALUES ('key2','value2');
 
29
 
 
30
INSERT INTO t1_non_trx VALUES ('key1','value1');
 
31
INSERT INTO t1_non_trx VALUES ('key2','value2');
 
32
 
 
33
ROLLBACK;
 
34
 
 
35
--echo Expected warning about non-trx data changes not being rolled back
 
36
 
 
37
SELECT * FROM t1_trx;
 
38
SELECT * FROM t1_non_trx;
 
39
 
 
40
START TRANSACTION;
 
41
 
 
42
INSERT INTO t1_trx VALUES ('key1','value1');
 
43
INSERT INTO t1_trx VALUES ('key2','value2');
 
44
 
 
45
SELECT t1_trx.k, t1_trx.v
 
46
FROM t1_trx
 
47
INNER JOIN t1_non_trx ON t1_trx.k = t1_non_trx.k;
 
48
 
 
49
ROLLBACK;
 
50
 
 
51
SELECT t1_trx.k, t1_trx.v
 
52
FROM t1_trx
 
53
INNER JOIN t1_non_trx ON t1_trx.k = t1_non_trx.k;
 
54
 
 
55
DROP TABLE t1_trx;
 
56
DROP TABLE t1_non_trx;