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
20 public class DeleteQueryAllPrimitivesTest extends JDBCQueryTest {
22 /** Test delete queries using AllPrimitives.
23 drop table if exists allprimitives;
24 create table allprimitives (
25 id int not null primary key,
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,
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,
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,
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,
65 public String tableName() {
66 return "allprimitives";
70 public void createInstances(int numberOfInstances) {
71 for (int i = 0; i < numberOfInstances; ++i) {
72 createAllPrimitiveInstance(i);
76 public void testDeleteEqualByPrimaryKey() {
77 deleteEqualQuery("id", "PRIMARY", 8, 1);
78 deleteEqualQuery("id", "PRIMARY", 8, 0);
79 equalQuery("id", "PRIMARY", 8);
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);
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);
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);
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);
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);