2 Copyright 2010 Sun Microsystems, Inc.
3 All rights reserved. Use is subject to license terms.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 package testsuite.clusterj;
21 import com.mysql.clusterj.query.Predicate;
23 import testsuite.clusterj.model.AllPrimitives;
25 /** Query for conditions beyond index values. Additional conditions
26 * are represented by multiple predicates joined via AND and OR.
27 * This test is based on QueryAllPrimitivesTest.
29 public class QueryExtraConditionsTest extends AbstractQueryTest {
32 public Class<?> getInstanceType() {
33 return AllPrimitives.class;
37 void createInstances(int number) {
38 createAllPrimitivesInstances(10);
41 /** Test queries with extra conditions using AllPrimitives.
42 drop table if exists allprimitives;
43 create table allprimitives (
44 id int not null primary key,
46 int_not_null_hash int not null,
47 int_not_null_btree int not null,
48 int_not_null_both int not null,
49 int_not_null_none int not null,
55 byte_not_null_hash tinyint not null,
56 byte_not_null_btree tinyint not null,
57 byte_not_null_both tinyint not null,
58 byte_not_null_none tinyint not null,
59 byte_null_hash tinyint,
60 byte_null_btree tinyint,
61 byte_null_both tinyint,
62 byte_null_none tinyint,
64 short_not_null_hash smallint not null,
65 short_not_null_btree smallint not null,
66 short_not_null_both smallint not null,
67 short_not_null_none smallint not null,
68 short_null_hash smallint,
69 short_null_btree smallint,
70 short_null_both smallint,
71 short_null_none smallint,
73 long_not_null_hash bigint not null,
74 long_not_null_btree bigint not null,
75 long_not_null_both bigint not null,
76 long_not_null_none bigint not null,
77 long_null_hash bigint,
78 long_null_btree bigint,
79 long_null_both bigint,
82 public void testExtraEqual() {
83 equalAnd1ExtraQuery("int_not_null_btree", 8, "int_null_none", extraEqualPredicateProvider, 8, "idx_int_not_null_btree", 8);
84 equalAnd1ExtraQuery("int_not_null_btree", 8, "int_null_none", extraEqualPredicateProvider, 9, "idx_int_not_null_btree");
86 equalAnd1ExtraQuery("int_not_null_hash", 8, "int_null_none", extraEqualPredicateProvider, 8, "none", 8);
87 equalAnd1ExtraQuery("int_not_null_hash", 8, "int_null_none", extraEqualPredicateProvider, 9, "none");
89 equalAnd1ExtraQuery("int_not_null_both", 8, "int_null_none", extraEqualPredicateProvider, 8, "idx_int_not_null_both", 8);
90 equalAnd1ExtraQuery("int_not_null_both", 8, "int_null_none", extraEqualPredicateProvider, 9, "idx_int_not_null_both");
92 equalAnd1ExtraQuery("int_not_null_none", 8, "int_null_none", extraEqualPredicateProvider, 8, "none", 8);
93 equalAnd1ExtraQuery("int_not_null_none", 8, "int_null_none", extraEqualPredicateProvider, 9, "none");
98 public void testExtraBetween() {
99 equalAnd2ExtraQuery("int_not_null_btree", 8, "int_null_none", extraBetweenPredicateProvider, 8, 9, "idx_int_not_null_btree", 8);
100 equalAnd2ExtraQuery("int_not_null_btree", 8, "int_null_none", extraBetweenPredicateProvider, 6, 7, "idx_int_not_null_btree");
102 equalAnd2ExtraQuery("int_not_null_hash", 8, "int_not_null_btree", extraBetweenPredicateProvider, 8, 9, "idx_int_not_null_btree", 8);
103 equalAnd2ExtraQuery("int_not_null_hash", 8, "int_not_null_btree", extraBetweenPredicateProvider, 6, 7, "idx_int_not_null_btree");
105 equalAnd2ExtraQuery("int_not_null_both", 8, "int_null_none", extraBetweenPredicateProvider, 8, 9, "idx_int_not_null_both", 8);
106 equalAnd2ExtraQuery("int_not_null_both", 8, "int_null_none", extraBetweenPredicateProvider, 6, 7, "idx_int_not_null_both");
108 equalAnd2ExtraQuery("int_not_null_none", 8, "int_not_null_btree", extraBetweenPredicateProvider, 8, 9, "idx_int_not_null_btree", 8);
109 equalAnd2ExtraQuery("int_not_null_none", 8, "int_not_null_btree", extraBetweenPredicateProvider, 6, 7, "idx_int_not_null_btree");