~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/r/ndb_index_unique.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
Import upstream version 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1, t2, t3, t4, t5, t6, t7, t8;
 
2
CREATE TABLE t1 (
 
3
a int NOT NULL PRIMARY KEY,
 
4
b int not null,
 
5
c int,
 
6
UNIQUE ib(b)
 
7
) engine=ndbcluster;
 
8
insert t1 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
 
9
select * from t1 order by b;
 
10
a       b       c
 
11
1       2       3
 
12
2       3       5
 
13
3       4       6
 
14
4       5       8
 
15
5       6       2
 
16
6       7       2
 
17
select * from t1 where b = 4 order by b;
 
18
a       b       c
 
19
3       4       6
 
20
insert into t1 values(7,8,3);
 
21
select * from t1 where b = 4 order by a;
 
22
a       b       c
 
23
3       4       6
 
24
insert into t1 values(8, 2, 3);
 
25
ERROR 23000: Duplicate entry '2' for key 'ib'
 
26
select * from t1 order by a;
 
27
a       b       c
 
28
1       2       3
 
29
2       3       5
 
30
3       4       6
 
31
4       5       8
 
32
5       6       2
 
33
6       7       2
 
34
7       8       3
 
35
delete from t1 where a = 1;
 
36
insert into t1 values(8, 2, 3);
 
37
select * from t1 order by a;
 
38
a       b       c
 
39
2       3       5
 
40
3       4       6
 
41
4       5       8
 
42
5       6       2
 
43
6       7       2
 
44
7       8       3
 
45
8       2       3
 
46
alter table t1 drop index ib;
 
47
insert into t1 values(1, 2, 3);
 
48
create unique index ib on t1(b);
 
49
ERROR 23000: Can't write, because of unique constraint, to table 't1'
 
50
drop table t1;
 
51
CREATE TABLE t1 (
 
52
a int unsigned NOT NULL PRIMARY KEY,
 
53
b int unsigned,
 
54
c int unsigned,
 
55
UNIQUE bc(b,c)
 
56
) engine = ndb;
 
57
insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL);
 
58
select * from t1 use index (bc) where b IS NULL order by a;
 
59
a       b       c
 
60
2       NULL    2
 
61
3       NULL    NULL
 
62
select * from t1 use index (bc)order by a;
 
63
a       b       c
 
64
1       1       1
 
65
2       NULL    2
 
66
3       NULL    NULL
 
67
4       4       NULL
 
68
select * from t1 use index (bc) order by a;
 
69
a       b       c
 
70
1       1       1
 
71
2       NULL    2
 
72
3       NULL    NULL
 
73
4       4       NULL
 
74
select * from t1 use index (PRIMARY) where b IS NULL order by a;
 
75
a       b       c
 
76
2       NULL    2
 
77
3       NULL    NULL
 
78
select * from t1 use index (bc) where b IS NULL order by a;
 
79
a       b       c
 
80
2       NULL    2
 
81
3       NULL    NULL
 
82
select * from t1 use index (bc) where b IS NULL and c IS NULL order by a;
 
83
a       b       c
 
84
3       NULL    NULL
 
85
select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
 
86
a       b       c
 
87
2       NULL    2
 
88
select * from t1 use index (bc) where b < 4 order by a;
 
89
a       b       c
 
90
1       1       1
 
91
select * from t1 use index (bc) where b IS NOT NULL order by a;
 
92
a       b       c
 
93
1       1       1
 
94
4       4       NULL
 
95
insert into t1 values(5,1,1);
 
96
ERROR 23000: Duplicate entry '1-1' for key 'bc'
 
97
drop table t1;
 
98
CREATE TABLE t2 (
 
99
a int unsigned NOT NULL PRIMARY KEY,
 
100
b int unsigned not null,
 
101
c int unsigned not null,
 
102
UNIQUE (b, c) USING HASH        
 
103
) engine=ndbcluster;
 
104
insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
 
105
select * from t2 where a = 3;
 
106
a       b       c
 
107
3       4       6
 
108
select * from t2 where b = 4;
 
109
a       b       c
 
110
3       4       6
 
111
select * from t2 where c = 6;
 
112
a       b       c
 
113
3       4       6
 
114
insert into t2 values(7,8,3);
 
115
select * from t2 where b = 4 order by a;
 
116
a       b       c
 
117
3       4       6
 
118
insert into t2 values(8, 2, 3);
 
119
ERROR 23000: Duplicate entry '2-3' for key 'b'
 
120
select * from t2 order by a;
 
121
a       b       c
 
122
1       2       3
 
123
2       3       5
 
124
3       4       6
 
125
4       5       8
 
126
5       6       2
 
127
6       7       2
 
128
7       8       3
 
129
delete from t2 where a = 1;
 
130
insert into t2 values(8, 2, 3);
 
131
select * from t2 order by a;
 
132
a       b       c
 
133
2       3       5
 
134
3       4       6
 
135
4       5       8
 
136
5       6       2
 
137
6       7       2
 
138
7       8       3
 
139
8       2       3
 
140
create unique index bi using hash on t2(b);
 
141
insert into t2 values(9, 3, 1);
 
142
ERROR 23000: Duplicate entry '3' for key 'bi'
 
143
alter table t2 drop index bi;
 
144
insert into t2 values(9, 3, 1);
 
145
select * from t2 order by a;
 
146
a       b       c
 
147
2       3       5
 
148
3       4       6
 
149
4       5       8
 
150
5       6       2
 
151
6       7       2
 
152
7       8       3
 
153
8       2       3
 
154
9       3       1
 
155
drop table t2;
 
156
CREATE TABLE t2 (
 
157
a int unsigned NOT NULL PRIMARY KEY,
 
158
b int unsigned not null,
 
159
c int unsigned,
 
160
UNIQUE (b, c) USING HASH        
 
161
) engine=ndbcluster;
 
162
Warnings:
 
163
Warning 1121    Ndb does not support unique index on NULL valued attributes, index access with NULL value will become full table scan
 
164
insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL);
 
165
select * from t2 where c IS NULL order by a;
 
166
a       b       c
 
167
1       1       NULL
 
168
3       3       NULL
 
169
5       5       NULL
 
170
7       7       NULL
 
171
8       3       NULL
 
172
9       3       NULL
 
173
select * from t2 where b = 3 AND c IS NULL order by a;
 
174
a       b       c
 
175
3       3       NULL
 
176
8       3       NULL
 
177
9       3       NULL
 
178
select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a;
 
179
a       b       c
 
180
3       3       NULL
 
181
5       5       NULL
 
182
8       3       NULL
 
183
9       3       NULL
 
184
set @old_ecpd = @@session.engine_condition_pushdown;
 
185
set engine_condition_pushdown = true;
 
186
explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
 
187
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
188
1       SIMPLE  t2      range   PRIMARY,b       PRIMARY 4       NULL    1       Using where with pushed condition
 
189
select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
 
190
a       b       c
 
191
3       3       NULL
 
192
5       5       NULL
 
193
8       3       NULL
 
194
set engine_condition_pushdown = @old_ecpd;
 
195
drop table t2;
 
196
CREATE TABLE t3 (
 
197
a int unsigned NOT NULL,
 
198
b int unsigned not null,
 
199
c int unsigned,
 
200
PRIMARY KEY (a, b) USING HASH         
 
201
) engine=ndbcluster;
 
202
insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
 
203
select * from t3 where a = 3;
 
204
a       b       c
 
205
3       4       6
 
206
select * from t3 where b = 4;
 
207
a       b       c
 
208
3       4       6
 
209
select * from t3 where c = 6;
 
210
a       b       c
 
211
3       4       6
 
212
insert into t3 values(7,8,3);
 
213
select * from t3 where b = 4 order by a;
 
214
a       b       c
 
215
3       4       6
 
216
drop table t3;
 
217
CREATE TABLE t1 (
 
218
pk int NOT NULL PRIMARY KEY,
 
219
a int unsigned,
 
220
UNIQUE KEY (a)
 
221
) engine=ndbcluster;
 
222
insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4);
 
223
select * from t1 order by pk;
 
224
pk      a
 
225
-1      NULL
 
226
0       0
 
227
1       NULL
 
228
2       2
 
229
3       NULL
 
230
4       4
 
231
insert into t1 values (5,0);
 
232
ERROR 23000: Duplicate entry '0' for key 'a'
 
233
select * from t1 order by pk;
 
234
pk      a
 
235
-1      NULL
 
236
0       0
 
237
1       NULL
 
238
2       2
 
239
3       NULL
 
240
4       4
 
241
delete from t1 where a = 0;
 
242
insert into t1 values (5,0);
 
243
select * from t1 order by pk;
 
244
pk      a
 
245
-1      NULL
 
246
1       NULL
 
247
2       2
 
248
3       NULL
 
249
4       4
 
250
5       0
 
251
CREATE TABLE t2 (
 
252
pk int NOT NULL PRIMARY KEY,
 
253
a int unsigned,
 
254
b tinyint NOT NULL,
 
255
c VARCHAR(10),
 
256
UNIQUE KEY si(a, c)
 
257
) engine=ndbcluster;
 
258
insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc');
 
259
select * from t2 order by pk;
 
260
pk      a       b       c
 
261
-1      1       17      NULL
 
262
0       NULL    18      NULL
 
263
1       3       19      abc
 
264
insert into t2 values(2,3,19,'abc');
 
265
ERROR 23000: Duplicate entry '3-abc' for key 'si'
 
266
select * from t2 order by pk;
 
267
pk      a       b       c
 
268
-1      1       17      NULL
 
269
0       NULL    18      NULL
 
270
1       3       19      abc
 
271
delete from t2 where c IS NOT NULL;
 
272
insert into t2 values(2,3,19,'abc');
 
273
select * from t2 order by pk;
 
274
pk      a       b       c
 
275
-1      1       17      NULL
 
276
0       NULL    18      NULL
 
277
2       3       19      abc
 
278
drop table t1, t2;
 
279
CREATE TABLE t1 (
 
280
cid smallint(5) unsigned NOT NULL default '0',
 
281
cv varchar(250) NOT NULL default '',
 
282
PRIMARY KEY  (cid),
 
283
UNIQUE KEY cv (cv)
 
284
) engine=ndbcluster;
 
285
INSERT INTO t1 VALUES (8,'dummy');
 
286
CREATE TABLE t2 (
 
287
cid bigint(20) unsigned NOT NULL auto_increment,
 
288
cap varchar(255) NOT NULL default '',
 
289
PRIMARY KEY  (cid),
 
290
UNIQUE KEY (cid, cap)
 
291
) engine=ndbcluster;
 
292
INSERT INTO t2 VALUES (NULL,'another dummy');
 
293
CREATE TABLE t3 (
 
294
gid bigint(20) unsigned NOT NULL auto_increment,
 
295
gn varchar(255) NOT NULL default '',
 
296
must tinyint(4) default NULL,
 
297
PRIMARY KEY  (gid)
 
298
) engine=ndbcluster;
 
299
INSERT INTO t3 VALUES (1,'V1',NULL);
 
300
CREATE TABLE t4 (
 
301
uid bigint(20) unsigned NOT NULL default '0',
 
302
gid bigint(20) unsigned NOT NULL,
 
303
rid bigint(20) unsigned NOT NULL,
 
304
cid bigint(20) unsigned NOT NULL,
 
305
UNIQUE KEY m (uid,gid,rid,cid)
 
306
) engine=ndbcluster;
 
307
INSERT INTO t4 VALUES (1,1,2,4);
 
308
INSERT INTO t4 VALUES (1,1,2,3);
 
309
INSERT INTO t4 VALUES (1,1,5,7);
 
310
INSERT INTO t4 VALUES (1,1,10,8);
 
311
CREATE TABLE t5 (
 
312
rid bigint(20) unsigned NOT NULL auto_increment,
 
313
rl varchar(255) NOT NULL default '',
 
314
PRIMARY KEY  (rid)
 
315
) engine=ndbcluster;
 
316
CREATE TABLE t6 (
 
317
uid bigint(20) unsigned NOT NULL auto_increment,
 
318
un varchar(250) NOT NULL default '',
 
319
uc smallint(5) unsigned NOT NULL default '0',
 
320
PRIMARY KEY  (uid),
 
321
UNIQUE KEY nc (un,uc)
 
322
) engine=ndbcluster;
 
323
INSERT INTO t6 VALUES (1,'test',8);
 
324
INSERT INTO t6 VALUES (2,'test2',9);
 
325
INSERT INTO t6 VALUES (3,'tre',3);
 
326
CREATE TABLE t7 (
 
327
mid bigint(20) unsigned NOT NULL PRIMARY KEY,
 
328
uid bigint(20) unsigned NOT NULL default '0',
 
329
gid bigint(20) unsigned NOT NULL,
 
330
rid bigint(20) unsigned NOT NULL,
 
331
cid bigint(20) unsigned NOT NULL,
 
332
UNIQUE KEY m (uid,gid,rid,cid)
 
333
) engine=ndbcluster;
 
334
INSERT INTO t7 VALUES(1, 1, 1, 1, 1);
 
335
INSERT INTO t7 VALUES(2, 2, 1, 1, 1);
 
336
INSERT INTO t7 VALUES(3, 3, 1, 1, 1);
 
337
INSERT INTO t7 VALUES(4, 4, 1, 1, 1);
 
338
INSERT INTO t7 VALUES(5, 5, 1, 1, 1);
 
339
INSERT INTO t7 VALUES(6, 1, 1, 1, 6);
 
340
INSERT INTO t7 VALUES(7, 2, 1, 1, 7);
 
341
INSERT INTO t7 VALUES(8, 3, 1, 1, 8);
 
342
INSERT INTO t7 VALUES(9, 4, 1, 1, 9);
 
343
INSERT INTO t7 VALUES(10, 5, 1, 1, 10);
 
344
select * from t1 where cv = 'dummy';
 
345
cid     cv
 
346
8       dummy
 
347
select * from t1 where cv = 'test';
 
348
cid     cv
 
349
select * from t2 where cap = 'another dummy';
 
350
cid     cap
 
351
1       another dummy
 
352
select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4;
 
353
uid     gid     rid     cid
 
354
1       1       2       4
 
355
select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4;
 
356
uid     gid     rid     cid
 
357
select * from t4 where uid = 1 order by cid;
 
358
uid     gid     rid     cid
 
359
1       1       2       3
 
360
1       1       2       4
 
361
1       1       5       7
 
362
1       1       10      8
 
363
select * from t4 where rid = 2 order by cid;
 
364
uid     gid     rid     cid
 
365
1       1       2       3
 
366
1       1       2       4
 
367
select * from t6 where un='test' and uc=8;
 
368
uid     un      uc
 
369
1       test    8
 
370
select * from t6 where un='test' and uc=7;
 
371
uid     un      uc
 
372
select * from t6 where un='test';
 
373
uid     un      uc
 
374
1       test    8
 
375
select * from t7 where mid = 8;
 
376
mid     uid     gid     rid     cid
 
377
8       3       1       1       8
 
378
select * from t7 where uid = 8;
 
379
mid     uid     gid     rid     cid
 
380
select * from t7 where uid = 1 order by mid;
 
381
mid     uid     gid     rid     cid
 
382
1       1       1       1       1
 
383
6       1       1       1       6
 
384
select * from t7 where uid = 4 order by mid;
 
385
mid     uid     gid     rid     cid
 
386
4       4       1       1       1
 
387
9       4       1       1       9
 
388
select * from t7 where gid = 4;
 
389
mid     uid     gid     rid     cid
 
390
select * from t7 where gid = 1 order by mid;
 
391
mid     uid     gid     rid     cid
 
392
1       1       1       1       1
 
393
2       2       1       1       1
 
394
3       3       1       1       1
 
395
4       4       1       1       1
 
396
5       5       1       1       1
 
397
6       1       1       1       6
 
398
7       2       1       1       7
 
399
8       3       1       1       8
 
400
9       4       1       1       9
 
401
10      5       1       1       10
 
402
select * from t7 where cid = 4;
 
403
mid     uid     gid     rid     cid
 
404
select * from t7 where cid = 8;
 
405
mid     uid     gid     rid     cid
 
406
8       3       1       1       8
 
407
select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4;
 
408
uid     gid     rid     cid
 
409
1       1       2       4
 
410
select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4;
 
411
uid     gid     rid     cid
 
412
select * from t4 where uid = 1 order by gid,cid;
 
413
uid     gid     rid     cid
 
414
1       1       2       3
 
415
1       1       2       4
 
416
1       1       5       7
 
417
1       1       10      8
 
418
1       1       5       12
 
419
1       2       5       12
 
420
1       3       9       11
 
421
1       3       5       12
 
422
1       4       5       12
 
423
1       5       5       12
 
424
1       6       5       12
 
425
1       7       5       12
 
426
1       8       5       12
 
427
1       9       5       12
 
428
1       10      5       12
 
429
1       11      5       12
 
430
1       12      5       12
 
431
1       13      5       12
 
432
1       14      5       12
 
433
1       15      5       12
 
434
1       16      5       12
 
435
1       17      5       12
 
436
1       18      5       12
 
437
1       19      5       12
 
438
1       20      5       12
 
439
1       21      5       12
 
440
1       22      5       12
 
441
1       23      5       12
 
442
1       24      5       12
 
443
1       25      5       12
 
444
1       26      5       12
 
445
1       27      5       12
 
446
1       28      5       12
 
447
1       29      5       12
 
448
1       30      5       12
 
449
1       31      5       12
 
450
1       32      5       12
 
451
1       33      5       12
 
452
1       34      5       12
 
453
1       35      5       12
 
454
1       36      5       12
 
455
1       37      5       12
 
456
1       38      5       12
 
457
1       39      5       12
 
458
1       40      5       12
 
459
1       41      5       12
 
460
1       42      5       12
 
461
1       43      5       12
 
462
1       44      5       12
 
463
1       45      5       12
 
464
1       46      5       12
 
465
1       47      5       12
 
466
1       48      5       12
 
467
1       49      5       12
 
468
1       50      5       12
 
469
1       51      5       12
 
470
1       52      5       12
 
471
1       53      5       12
 
472
1       54      5       12
 
473
1       55      5       12
 
474
1       56      5       12
 
475
1       57      5       12
 
476
1       58      5       12
 
477
1       59      5       12
 
478
1       60      5       12
 
479
1       61      5       12
 
480
1       62      5       12
 
481
1       63      5       12
 
482
1       64      5       12
 
483
1       65      5       12
 
484
1       66      5       12
 
485
1       67      5       12
 
486
1       68      5       12
 
487
1       69      5       12
 
488
1       70      5       12
 
489
1       71      5       12
 
490
1       72      5       12
 
491
1       73      5       12
 
492
1       74      5       12
 
493
1       75      5       12
 
494
1       76      5       12
 
495
1       77      5       12
 
496
1       78      5       12
 
497
1       79      5       12
 
498
1       80      5       12
 
499
1       81      5       12
 
500
1       82      5       12
 
501
1       83      5       12
 
502
1       84      5       12
 
503
1       85      5       12
 
504
1       86      5       12
 
505
1       87      5       12
 
506
1       88      5       12
 
507
1       89      5       12
 
508
1       90      5       12
 
509
1       91      5       12
 
510
1       92      5       12
 
511
1       93      5       12
 
512
1       94      5       12
 
513
1       95      5       12
 
514
1       96      5       12
 
515
1       97      5       12
 
516
1       98      5       12
 
517
1       99      5       12
 
518
1       100     5       12
 
519
select * from t4 where uid = 1 order by gid,cid;
 
520
uid     gid     rid     cid
 
521
1       1       2       3
 
522
1       1       2       4
 
523
1       1       5       7
 
524
1       1       10      8
 
525
1       1       5       12
 
526
1       2       5       12
 
527
1       3       9       11
 
528
1       3       5       12
 
529
1       4       5       12
 
530
1       5       5       12
 
531
1       6       5       12
 
532
1       7       5       12
 
533
1       8       5       12
 
534
1       9       5       12
 
535
1       10      5       12
 
536
1       11      5       12
 
537
1       12      5       12
 
538
1       13      5       12
 
539
1       14      5       12
 
540
1       15      5       12
 
541
1       16      5       12
 
542
1       17      5       12
 
543
1       18      5       12
 
544
1       19      5       12
 
545
1       20      5       12
 
546
1       21      5       12
 
547
1       22      5       12
 
548
1       23      5       12
 
549
1       24      5       12
 
550
1       25      5       12
 
551
1       26      5       12
 
552
1       27      5       12
 
553
1       28      5       12
 
554
1       29      5       12
 
555
1       30      5       12
 
556
1       31      5       12
 
557
1       32      5       12
 
558
1       33      5       12
 
559
1       34      5       12
 
560
1       35      5       12
 
561
1       36      5       12
 
562
1       37      5       12
 
563
1       38      5       12
 
564
1       39      5       12
 
565
1       40      5       12
 
566
1       41      5       12
 
567
1       42      5       12
 
568
1       43      5       12
 
569
1       44      5       12
 
570
1       45      5       12
 
571
1       46      5       12
 
572
1       47      5       12
 
573
1       48      5       12
 
574
1       49      5       12
 
575
1       50      5       12
 
576
1       51      5       12
 
577
1       52      5       12
 
578
1       53      5       12
 
579
1       54      5       12
 
580
1       55      5       12
 
581
1       56      5       12
 
582
1       57      5       12
 
583
1       58      5       12
 
584
1       59      5       12
 
585
1       60      5       12
 
586
1       61      5       12
 
587
1       62      5       12
 
588
1       63      5       12
 
589
1       64      5       12
 
590
1       65      5       12
 
591
1       66      5       12
 
592
1       67      5       12
 
593
1       68      5       12
 
594
1       69      5       12
 
595
1       70      5       12
 
596
1       71      5       12
 
597
1       72      5       12
 
598
1       73      5       12
 
599
1       74      5       12
 
600
1       75      5       12
 
601
1       76      5       12
 
602
1       77      5       12
 
603
1       78      5       12
 
604
1       79      5       12
 
605
1       80      5       12
 
606
1       81      5       12
 
607
1       82      5       12
 
608
1       83      5       12
 
609
1       84      5       12
 
610
1       85      5       12
 
611
1       86      5       12
 
612
1       87      5       12
 
613
1       88      5       12
 
614
1       89      5       12
 
615
1       90      5       12
 
616
1       91      5       12
 
617
1       92      5       12
 
618
1       93      5       12
 
619
1       94      5       12
 
620
1       95      5       12
 
621
1       96      5       12
 
622
1       97      5       12
 
623
1       98      5       12
 
624
1       99      5       12
 
625
1       100     5       12
 
626
select * from t4 where rid = 2 order by cid;
 
627
uid     gid     rid     cid
 
628
1       1       2       3
 
629
1       1       2       4
 
630
drop table t1,t2,t3,t4,t5,t6,t7;
 
631
CREATE TABLE t1 (   
 
632
a int unsigned NOT NULL PRIMARY KEY,
 
633
b int unsigned,   
 
634
c int unsigned, 
 
635
UNIQUE bc(b,c) ) engine = ndb;
 
636
insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL);
 
637
select * from t1 where b=1 and c=1;
 
638
a       b       c
 
639
1       1       1
 
640
select * from t1 where b is null and c is null;
 
641
a       b       c
 
642
3       NULL    NULL
 
643
select * from t1 where b is null and c = 2;
 
644
a       b       c
 
645
2       NULL    2
 
646
select * from t1 where b = 4 and c is null;
 
647
a       b       c
 
648
4       4       NULL
 
649
create table t8 as 
 
650
select * from t1 where (b = 1 and c = 1)
 
651
or (b is null and c is null) 
 
652
or (b is null and c = 2)
 
653
or (b = 4 and c is null);
 
654
select * from t8 order by a;
 
655
a       b       c
 
656
1       1       1
 
657
2       NULL    2
 
658
3       NULL    NULL
 
659
4       4       NULL
 
660
select * from t1 order by a;
 
661
a       b       c
 
662
1       1       1
 
663
2       NULL    2
 
664
3       NULL    NULL
 
665
4       4       NULL
 
666
drop table t1, t8;
 
667
create table t1(
 
668
id integer not null auto_increment,
 
669
month integer not null,
 
670
year integer not null,
 
671
code varchar( 2) not null,
 
672
primary key ( id),
 
673
unique idx_t1( month, code, year)
 
674
) engine=ndb;
 
675
INSERT INTO t1 (month, year, code) VALUES (4,2004,'12');
 
676
INSERT INTO t1 (month, year, code) VALUES (5,2004,'12');
 
677
select * from t1 where code = '12' and month = 4 and year = 2004 ;
 
678
id      month   year    code
 
679
1       4       2004    12
 
680
drop table t1;
 
681
create table t1 (a int primary key, b varchar(1000) not null, unique key (b))
 
682
engine=ndb charset=utf8;
 
683
insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200));
 
684
insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200));
 
685
ERROR 23000: Duplicate entry '∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫dt∫d' for key 'b'
 
686
select a, sha1(b) from t1;
 
687
a       sha1(b)
 
688
1       08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d
 
689
drop table t1;
 
690
create table t1(id int not null) engine = NDB;
 
691
alter table t1 add constraint uk_test unique (id) using hash;
 
692
drop table t1;