~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to plugin/transaction_log/tests/t/replace.inc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
2
# Simple test of the transaction log for testing REPLACE command 
 
3
 
4
# We create a table then fill it with a few records and then
 
5
# issue a few REPLACE statements on it.
 
6
#
 
7
 
 
8
--disable_warnings
 
9
DROP TABLE IF EXISTS t1, t2;
 
10
--enable_warnings
 
11
 
 
12
CREATE TABLE t1 (
 
13
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
 
14
, padding VARCHAR(200) NOT NULL
 
15
) ENGINE=InnoDB;
 
16
 
 
17
INSERT INTO t1 VALUES (1, "I love testing.");
 
18
INSERT INTO t1 VALUES (2, "I hate testing.");
 
19
 
 
20
# This will actually execute an UPDATE for InnoDB, 
 
21
# as this is an optimized scenario that can have the
 
22
# REPLACE INTO converted into an INSERT ... ON DUPLICATE
 
23
# KEY UPDATE.
 
24
 
 
25
REPLACE INTO t1 VALUE (2, "I love testing.");
 
26
 
 
27
DROP TABLE t1;
 
28
 
 
29
CREATE TABLE t1 (
 
30
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
 
31
, padding VARCHAR(200) NOT NULL
 
32
) ENGINE=InnoDB;
 
33
CREATE TABLE t2 (
 
34
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
 
35
, fk_id INT NOT NULL
 
36
, CONSTRAINT fk_t1 FOREIGN KEY (fk_id) REFERENCES t1 (id) ON DELETE CASCADE
 
37
) ENGINE=InnoDB;
 
38
 
 
39
INSERT INTO t1 VALUES (1, "I love testing.");
 
40
INSERT INTO t1 VALUES (2, "I hate testing.");
 
41
 
 
42
# Should delete original and insert a new one
 
43
# with a different "padding" column value...
 
44
 
 
45
REPLACE INTO t1 VALUE (2, "I love testing.");
 
46
 
 
47
DROP TABLE t2, t1;