2 Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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.
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.
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
18 package testsuite.clusterj;
20 import testsuite.clusterj.model.AllPrimitives;
21 import testsuite.clusterj.model.IdBase;
23 public class DeleteQueryAllPrimitivesTest extends AbstractQueryTest {
26 public Class getInstanceType() {
27 return AllPrimitives.class;
31 void createInstances(int number) {
32 createAllPrimitivesInstances(10);
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,
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,
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,
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,
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,
77 public void testDeleteEqualByPrimaryKey() {
78 deleteEqualQuery("id", "PRIMARY", 8, 1);
79 deleteEqualQuery("id", "PRIMARY", 8, 0);
80 equalQuery("id", "PRIMARY", 8);
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);
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);
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);
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);
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);
119 public void testDeleteEqualByPrimaryKeyAutotransaction() {
120 setAutotransaction(true);
121 deleteEqualQuery("id", "PRIMARY", 8, 1);
122 deleteEqualQuery("id", "PRIMARY", 8, 0);
123 equalQuery("id", "PRIMARY", 8);
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);
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);
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);
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);
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);