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