1 -- source include/have_ndb.inc
4 drop
table if exists t1, t2, t3, t4;
8 K INT NOT NULL AUTO_INCREMENT,
14 partition by key (K) partitions 1;
16 INSERT INTO t10(I,J) VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0);
18 CREATE
TABLE t100 LIKE t10;
20 SELECT X.J, X.J+(10*Y.J) FROM t10 AS X,t10 AS Y;
22 CREATE
TABLE t10000 LIKE t10;
24 # Insert into t10000 in two chunks to not
25 # exhaust MaxNoOfConcurrentOperations
26 INSERT INTO t10000(I,J)
27 SELECT X.J, X.J+(100*Y.J) FROM t100 AS X,t100 AS Y
29 INSERT INTO t10000(I,J)
30 SELECT X.J, X.J+(100*Y.J) FROM t100 AS X,t100 AS Y
33 ANALYZE
TABLE t10,t100,t10000;
35 SELECT COUNT(*) FROM t10;
36 SELECT COUNT(*) FROM t100;
37 SELECT COUNT(*) FROM t10000;
40 # Bug #59517: Incorrect detection of single row access in
41 # ha_ndbcluster::records_in_range()
43 # Expect a single row (or const) when PK is excact specified
45 SELECT * FROM t10000 WHERE k = 42;
47 # All queries below should *not* return a single row
49 SELECT * FROM t10000 WHERE k >= 42 and k < 10000;
51 SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000;
53 SELECT * FROM t10000 WHERE k < 42;
55 SELECT * FROM t10000 WHERE k > 42;
58 # Bug #59519 ::set_rec_per_key() assumes ORDER_INDEX to be unique
61 # 'REF' join of 'Y' should match >1 rows
63 SELECT * FROM t10000 AS X
JOIN t10000 AS Y
64 ON Y.I=X.I AND Y.J = X.I;
67 # Bug #11804277: INCORRECT INDEX MAY BE SELECTED DUE TO INSUFFICIENT
68 # STATISTICS FROM CLUSTER
71 # Open bounded range should return 10% of #rows in table
73 SELECT * FROM t100 WHERE k < 42;
75 SELECT * FROM t100 WHERE k > 42;
77 SELECT * FROM t10000 WHERE k < 42;
79 SELECT * FROM t10000 WHERE k > 42;
81 #Closed bounded range should return 5% of #rows in table
83 SELECT * FROM t100 WHERE k BETWEEN 42 AND 10000;
85 SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000;
87 #EQ-range selectivity depends on
88 # - key length specified
90 # - unique/non-unique index
91 # - min 2% selectivity
93 # Possibly combined with open/closed ranges as
94 # above which further improves selectivity
97 SELECT * FROM t10000 WHERE I = 0;
99 SELECT * FROM t10000 WHERE J = 0;
102 SELECT * FROM t10000 WHERE I = 0 AND J = 0;
105 SELECT * FROM t10000 WHERE I = 0;
107 SELECT * FROM t10000 WHERE I = 0 AND J > 1;
109 SELECT * FROM t10000 WHERE I = 0 AND J < 1;
111 SELECT * FROM t10000 WHERE I = 0 AND J BETWEEN 1 AND 10;
113 SELECT * FROM t10000 WHERE I = 0 AND J = 1;
116 SELECT * FROM t10000 WHERE J = 0;
118 SELECT * FROM t10000 WHERE J = 0 AND K > 1;
120 SELECT * FROM t10000 WHERE J = 0 AND K < 1;
122 SELECT * FROM t10000 WHERE J = 0 AND K BETWEEN 1 AND 10;
124 SELECT * FROM t10000 WHERE J = 0 AND K = 1;
126 ## Verify selection of 'best' index
127 ## (The one of index I/J being EQ)
129 SELECT * FROM t10000 WHERE I = 0 AND J <> 1;
131 SELECT * FROM t10000 WHERE I <> 0 AND J = 1;
133 SELECT * FROM t10000 WHERE I <> 0 AND J <> 1;
136 SELECT * FROM t10000 WHERE J <> 1 AND I = 0;
138 SELECT * FROM t10000 WHERE J = 1 AND I <> 0;
140 SELECT * FROM t10000 WHERE J <> 1 AND I <> 0;
143 DROP
TABLE t10,t100,t10000;
145 --echo End of 5.1 tests