]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
34818421e5b5bb04abe1e3ed6c2e1434c47e5363
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17
18 package testsuite.clusterj;
19
20 import testsuite.clusterj.model.AllPrimitives;
21 import testsuite.clusterj.model.IdBase;
22
23 public class DeleteQueryAllPrimitivesTest extends AbstractQueryTest {
24
25     @Override
26     public Class getInstanceType() {
27         return AllPrimitives.class;
28     }
29
30     @Override
31     void createInstances(int number) {
32         createAllPrimitivesInstances(10);
33     }
34
35     /** Test all single-predicate queries using AllPrimitives.
36 drop table if exists allprimitives;
37 create table allprimitives (
38  id int not null primary key,
39
40  int_not_null_hash int not null,
41  int_not_null_btree int not null,
42  int_not_null_both int not null,
43  int_not_null_none int not null,
44  int_null_hash int,
45  int_null_btree int,
46  int_null_both int,
47  int_null_none int,
48
49  byte_not_null_hash tinyint not null,
50  byte_not_null_btree tinyint not null,
51  byte_not_null_both tinyint not null,
52  byte_not_null_none tinyint not null,
53  byte_null_hash tinyint,
54  byte_null_btree tinyint,
55  byte_null_both tinyint,
56  byte_null_none tinyint,
57
58  short_not_null_hash smallint not null,
59  short_not_null_btree smallint not null,
60  short_not_null_both smallint not null,
61  short_not_null_none smallint not null,
62  short_null_hash smallint,
63  short_null_btree smallint,
64  short_null_both smallint,
65  short_null_none smallint,
66
67  long_not_null_hash bigint not null,
68  long_not_null_btree bigint not null,
69  long_not_null_both bigint not null,
70  long_not_null_none bigint not null,
71  long_null_hash bigint,
72  long_null_btree bigint,
73  long_null_both bigint,
74  long_null_none bigint
75      */
76
77     public void testDeleteEqualByPrimaryKey() {
78         deleteEqualQuery("id", "PRIMARY", 8, 1);
79         deleteEqualQuery("id", "PRIMARY", 8, 0);
80         equalQuery("id", "PRIMARY", 8);
81         failOnError();
82     }
83
84     public void testDeleteEqualByUniqueKey() {
85         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 1);
86         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 0);
87         equalQuery("int_not_null_hash", "idx_int_not_null_hash", 8);
88         failOnError();
89     }
90
91     public void testDeleteEqualByBtreeIndex() {
92         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 1);
93         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 0);
94         equalQuery("int_not_null_btree", "idx_int_not_null_btree", 8);
95         failOnError();
96     }
97
98     public void testDeleteEqualByTableScan() {
99         deleteEqualQuery("int_not_null_none", "none", 8, 1);
100         deleteEqualQuery("int_not_null_none", "none", 8, 0);
101         equalQuery("int_not_null_none", "none", 8);
102         failOnError();
103     }
104
105     public void testDeleteRangeByBtreeIndex() {
106         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 2);
107         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 0);
108         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
109         failOnError();
110     }
111
112     public void testDeleteRangeByTableScan() {
113         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 2);
114         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 0);
115         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
116         failOnError();
117     }
118
119     public void testDeleteEqualByPrimaryKeyAutotransaction() {
120         setAutotransaction(true);
121         deleteEqualQuery("id", "PRIMARY", 8, 1);
122         deleteEqualQuery("id", "PRIMARY", 8, 0);
123         equalQuery("id", "PRIMARY", 8);
124         failOnError();
125     }
126
127     public void testDeleteEqualByUniqueKeyAutotransaction() {
128         setAutotransaction(true);
129         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 1);
130         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 0);
131         equalQuery("int_not_null_hash", "idx_int_not_null_hash", 8);
132         failOnError();
133     }
134
135     public void testDeleteEqualByBtreeIndexAutotransaction() {
136         setAutotransaction(true);
137         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 1);
138         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 0);
139         equalQuery("int_not_null_btree", "idx_int_not_null_btree", 8);
140         failOnError();
141     }
142
143     public void testDeleteEqualByTableScanAutotransaction() {
144         setAutotransaction(true);
145         deleteEqualQuery("int_not_null_none", "none", 8, 1);
146         deleteEqualQuery("int_not_null_none", "none", 8, 0);
147         equalQuery("int_not_null_none", "none", 8);
148         failOnError();
149     }
150
151     public void testDeleteRangeByBtreeIndexAutotransaction() {
152         setAutotransaction(true);
153         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 2);
154         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 0);
155         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
156         failOnError();
157     }
158
159     public void testDeleteRangeByTableScanAutotransaction() {
160         setAutotransaction(true);
161         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 2);
162         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 0);
163         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
164         failOnError();
165     }
166
167 }