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 testsuite.clusterj.model.AllPrimitives;
23 import com.mysql.clusterj.ClusterJUserException;
25 /** Query for columns compared to null. Comparisons using greaterThan,
26 * greaterEqual, lessThan, and lessEqual throw ClusterJUserException.
27 * Predicates using equal null cannot use indexes, although indexes can
28 * be used for non-null comparisons.
29 * This test is based on QueryExtraConditionsTest.
31 public class QueryNullTest extends AbstractQueryTest {
33 drop table if exists allprimitives;
34 create table allprimitives (
35 id int not null primary key,
37 int_not_null_hash int not null,
38 int_not_null_btree int not null,
39 int_not_null_both int not null,
40 int_not_null_none int not null,
46 byte_not_null_hash tinyint not null,
47 byte_not_null_btree tinyint not null,
48 byte_not_null_both tinyint not null,
49 byte_not_null_none tinyint not null,
50 byte_null_hash tinyint,
51 byte_null_btree tinyint,
52 byte_null_both tinyint,
53 byte_null_none tinyint,
55 short_not_null_hash smallint not null,
56 short_not_null_btree smallint not null,
57 short_not_null_both smallint not null,
58 short_not_null_none smallint not null,
59 short_null_hash smallint,
60 short_null_btree smallint,
61 short_null_both smallint,
62 short_null_none smallint,
64 long_not_null_hash bigint not null,
65 long_not_null_btree bigint not null,
66 long_not_null_both bigint not null,
67 long_not_null_none bigint not null,
68 long_null_hash bigint,
69 long_null_btree bigint,
70 long_null_both bigint,
75 public Class<?> getInstanceType() {
76 return AllPrimitives.class;
80 void createInstances(int number) {
81 createAllPrimitivesInstances(10);
84 public void testExtraEqualNull() {
85 equalAnd1ExtraQuery("int_not_null_btree", 8, "int_null_none", extraEqualPredicateProvider, null, "idx_int_not_null_btree");
86 equalAnd1ExtraQuery("int_not_null_hash", 8, "int_null_none", extraEqualPredicateProvider, null, "none");
87 equalAnd1ExtraQuery("int_not_null_both", 8, "int_null_none", extraEqualPredicateProvider, null, "idx_int_not_null_both");
88 equalAnd1ExtraQuery("int_not_null_none", 8, "int_null_none", extraEqualPredicateProvider, null, "none");
92 public void testBtreeEqualNull() {
93 equalQuery("int_not_null_btree", "none", null);
94 equalQuery("int_null_btree", "none", null);
98 public void testHashEqualNull() {
99 equalQuery("int_not_null_hash", "none", null);
100 equalQuery("int_null_hash", "none", null);
104 public void testBothEqualNull() {
105 equalQuery("int_not_null_both", "none", null);
106 equalQuery("int_null_both", "none", null);
110 public void testNoneEqualNull() {
111 equalQuery("int_not_null_none", "none", null);
112 equalQuery("int_null_none", "none", null);
116 public void testGreaterThanNull() {
118 greaterThanQuery("int_not_null_btree", "none", null);
119 error("Greater than query should throw ClusterJUserException with null parameter.");
120 } catch (ClusterJUserException ex) {
125 public void testGreaterEqualNull() {
127 greaterEqualQuery("int_not_null_btree", "none", null);
128 error("Greater equal query should throw ClusterJUserException with null parameter.");
129 } catch (ClusterJUserException ex) {
134 public void testLessThanNull() {
136 lessThanQuery("int_not_null_btree", "none", null);
137 error("Less than query should throw ClusterJUserException with null parameter.");
138 } catch (ClusterJUserException ex) {
143 public void testLessEqualNull() {
145 lessEqualQuery("int_not_null_btree", "none", null);
146 error("Less equal query should throw ClusterJUserException with null parameter.");
147 } catch (ClusterJUserException ex) {