]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
205414755f0d7e9923df5ef2fc7b5a2f238ebc9e
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright 2010 Sun Microsystems, Inc.
3    All rights reserved. Use is subject to license terms.
4
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.
8
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.
13
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
17 */
18
19 package testsuite.clusterj;
20
21 import com.mysql.clusterj.query.Predicate;
22
23 import testsuite.clusterj.model.AllPrimitives;
24
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.
28  */
29 public class QueryExtraConditionsTest extends AbstractQueryTest {
30
31     @Override
32     public Class<?> getInstanceType() {
33         return AllPrimitives.class;
34     }
35
36     @Override
37     void createInstances(int number) {
38         createAllPrimitivesInstances(10);
39     }
40
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,
45
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,
50  int_null_hash int,
51  int_null_btree int,
52  int_null_both int,
53  int_null_none int,
54
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,
63
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,
72
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,
80  long_null_none bigint
81      */
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");
85
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");
88
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");
91
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");
94
95         failOnError();        
96     }
97
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");
101
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");
104
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");
107
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");
110
111         failOnError();        
112     }
113
114 }