]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
a92e9ad46b8e734e70db6cdb938e647177657b01
[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 jdbctest;
19
20 public class DeleteQueryAllPrimitivesTest extends JDBCQueryTest {
21
22     /** Test delete queries using AllPrimitives.
23 drop table if exists allprimitives;
24 create table allprimitives (
25  id int not null primary key,
26
27  int_not_null_hash int not null,
28  int_not_null_btree int not null,
29  int_not_null_both int not null,
30  int_not_null_none int not null,
31  int_null_hash int,
32  int_null_btree int,
33  int_null_both int,
34  int_null_none int,
35
36  byte_not_null_hash tinyint not null,
37  byte_not_null_btree tinyint not null,
38  byte_not_null_both tinyint not null,
39  byte_not_null_none tinyint not null,
40  byte_null_hash tinyint,
41  byte_null_btree tinyint,
42  byte_null_both tinyint,
43  byte_null_none tinyint,
44
45  short_not_null_hash smallint not null,
46  short_not_null_btree smallint not null,
47  short_not_null_both smallint not null,
48  short_not_null_none smallint not null,
49  short_null_hash smallint,
50  short_null_btree smallint,
51  short_null_both smallint,
52  short_null_none smallint,
53
54  long_not_null_hash bigint not null,
55  long_not_null_btree bigint not null,
56  long_not_null_both bigint not null,
57  long_not_null_none bigint not null,
58  long_null_hash bigint,
59  long_null_btree bigint,
60  long_null_both bigint,
61  long_null_none bigint
62      */
63
64     @Override
65     public String tableName() {
66         return "allprimitives";
67     }
68
69     @Override
70     public void createInstances(int numberOfInstances) {
71         for (int i = 0; i < numberOfInstances; ++i) {
72             createAllPrimitiveInstance(i);
73         }
74     }
75
76     public void testDeleteEqualByPrimaryKey() {
77         deleteEqualQuery("id", "PRIMARY", 8, 1);
78         deleteEqualQuery("id", "PRIMARY", 8, 0);
79         equalQuery("id", "PRIMARY", 8);
80         failOnError();
81     }
82
83     public void testDeleteEqualByUniqueKey() {
84         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 1);
85         deleteEqualQuery("int_not_null_hash", "idx_int_not_null_hash", 8, 0);
86         equalQuery("int_not_null_hash", "idx_int_not_null_hash", 8);
87         failOnError();
88     }
89
90     public void testDeleteEqualByBtreeIndex() {
91         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 1);
92         deleteEqualQuery("int_not_null_btree", "idx_int_not_null_btree", 8, 0);
93         equalQuery("int_not_null_btree", "idx_int_not_null_btree", 8);
94         failOnError();
95     }
96
97     public void testDeleteEqualByTableScan() {
98         deleteEqualQuery("int_not_null_none", "none", 8, 1);
99         deleteEqualQuery("int_not_null_none", "none", 8, 0);
100         equalQuery("int_not_null_none", "none", 8);
101         failOnError();
102     }
103
104     public void testDeleteRangeByBtreeIndex() {
105         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 2);
106         deleteGreaterThanAndLessThanQuery("int_not_null_btree", "idx_int_not_null_btree", 4, 7, 0);
107         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
108         failOnError();
109     }
110
111     public void testDeleteRangeByTableScan() {
112         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 2);
113         deleteGreaterThanAndLessThanQuery("int_not_null_none", "none", 4, 7, 0);
114         betweenQuery("int_not_null_btree", "idx_int_not_null_btree", 3, 8, 3, 4, 7, 8);
115         failOnError();
116     }
117
118 }