~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/transaction_log/tests/t/update.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 serial event log for UPDATE statements
 
3
 
4
# We create a table and insert some records
 
5
# into it.  We then update the table.
 
6
 
7
#
 
8
 
 
9
--disable_warnings
 
10
DROP TABLE IF EXISTS t1;
 
11
--enable_warnings
 
12
 
 
13
CREATE TABLE t1 (
 
14
  id INT NOT NULL
 
15
, padding VARCHAR(200) NOT NULL
 
16
, PRIMARY KEY (id)
 
17
);
 
18
 
 
19
INSERT INTO t1 VALUES (1, "I love testing.");
 
20
INSERT INTO t1 VALUES (2, "I hate testing.");
 
21
 
 
22
# Simple PK update
 
23
UPDATE t1 SET padding= "XXX" WHERE id= 1;
 
24
 
 
25
# UPDATE all records in table
 
26
UPDATE t1 SET padding= "AAA";
 
27
 
 
28
DROP TABLE t1;
 
29
 
 
30
# Test for LP Bug#440141:
 
31
#
 
32
# Replication generates incorrect update commands when 
 
33
# where clause uses a field contained in set clause
 
34
#
 
35
CREATE TABLE t1 (
 
36
  id int AUTO_INCREMENT NOT NULL PRIMARY KEY
 
37
, name varchar(1024)
 
38
, alias varchar(1024)
 
39
);
 
40
 
 
41
INSERT INTO t1 (name,alias) VALUES ("jeff lebowski","dude");
 
42
 
 
43
UPDATE t1 SET alias = "the dude" WHERE alias = "dude";
 
44
 
 
45
DROP TABLE t1;
 
46
 
 
47
# Tests UPDATE statement which changes an existing row
 
48
# by referencing the changed field.
 
49
 
 
50
CREATE TABLE t1 (
 
51
  id INT NOT NULL
 
52
, counter INT NOT NULL
 
53
, PRIMARY KEY (id)
 
54
);
 
55
 
 
56
INSERT INTO t1 (id, counter) VALUES (1,1),(2,2),(3,3);
 
57
 
 
58
UPDATE t1 SET counter = counter + 1 WHERE id = 1;
 
59
UPDATE t1 SET counter = counter + 1 WHERE id IN (2,3);
 
60
 
 
61
DROP TABLE t1;
 
62
 
 
63
# Test for updating a primary key value
 
64
# in an UPDATE statement.  LP Bug#480710
 
65
 
 
66
CREATE TABLE t1 (
 
67
  id INT NOT NULL
 
68
, padding VARCHAR(200) NOT NULL
 
69
, PRIMARY KEY (id)
 
70
);
 
71
 
 
72
INSERT INTO t1 VALUES (1, "I love testing.");
 
73
INSERT INTO t1 VALUES (2, "I hate testing.");
 
74
 
 
75
UPDATE t1 SET id = 4 WHERE id = 2;
 
76
 
 
77
DROP TABLE t1;