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

« back to all changes in this revision

Viewing changes to mysql-test/t/partition_error.test

  • 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
#
 
2
# Simple test for the erroneos statements using the 
 
3
# partition storage engine
 
4
#
 
5
-- source include/have_partition.inc
 
6
 
 
7
--disable_warnings
 
8
drop table if exists t1;
 
9
--enable_warnings
 
10
 
 
11
#
 
12
# Bug#38719: Partitioning returns a different error code for a
 
13
# duplicate key error
 
14
CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
 
15
-- error ER_DUP_ENTRY
 
16
INSERT INTO t1 VALUES (1),(1);
 
17
DROP TABLE t1;
 
18
CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a))
 
19
PARTITION BY KEY (a) PARTITIONS 2;
 
20
-- error ER_DUP_ENTRY
 
21
INSERT INTO t1 VALUES (1),(1);
 
22
DROP TABLE t1;
 
23
 
 
24
#
 
25
# Bug#31931: Mix of handlers error message
 
26
#
 
27
--error ER_MIX_HANDLER_ERROR
 
28
CREATE TABLE t1 (a INT)
 
29
PARTITION BY HASH (a)
 
30
( PARTITION p0 ENGINE=MyISAM,
 
31
  PARTITION p1);
 
32
--error ER_MIX_HANDLER_ERROR
 
33
CREATE TABLE t1 (a INT)
 
34
PARTITION BY LIST (a)
 
35
SUBPARTITION BY HASH (a)
 
36
( PARTITION p0 VALUES IN (0)
 
37
( SUBPARTITION s0, SUBPARTITION s1 ENGINE=MyISAM, SUBPARTITION s2),
 
38
  PARTITION p1 VALUES IN (1)
 
39
( SUBPARTITION s3 ENGINE=MyISAM, SUBPARTITION s4, SUBPARTITION s5 ENGINE=MyISAM));
 
40
 
 
41
 
 
42
#
 
43
# Bug 29368:
 
44
# Incorrect error, 1467, for syntax error when creating partition
 
45
--error ER_PARTITION_REQUIRES_VALUES_ERROR
 
46
CREATE TABLE t1 (
 
47
  a int
 
48
)
 
49
PARTITION BY RANGE (a)
 
50
(
 
51
  PARTITION p0 VALUES LESS THAN (1),
 
52
  PARTITION p1 VALU ES LESS THAN (2)
 
53
);
 
54
 
 
55
#
 
56
# Partition by key stand-alone error
 
57
#
 
58
--error 1064
 
59
partition by list (a)
 
60
partitions 3
 
61
(partition x1 values in (1,2,9,4) tablespace ts1,
 
62
 partition x2 values in (3, 11, 5, 7) tablespace ts2,
 
63
 partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
 
64
 
 
65
#
 
66
# Partition by key list, number of partitions defined, no partition defined
 
67
#
 
68
--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
 
69
CREATE TABLE t1 (
 
70
a int not null,
 
71
b int not null,
 
72
c int not null,
 
73
primary key(a,b))
 
74
partition by list (a)
 
75
partitions 2;
 
76
 
 
77
#
 
78
# Partition by key list, wrong result type
 
79
#
 
80
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
81
CREATE TABLE t1 (
 
82
a int not null,
 
83
b int not null,
 
84
c int not null,
 
85
primary key(a,b))
 
86
partition by list (sin(a))
 
87
partitions 3
 
88
(partition x1 values in (1,2,9,4) tablespace ts1,
 
89
 partition x2 values in (3, 11, 5, 7) tablespace ts2,
 
90
 partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
 
91
 
 
92
#
 
93
# Partition by key, partition function not allowed
 
94
#
 
95
--error 1064
 
96
CREATE TABLE t1 (
 
97
a int not null,
 
98
b int not null,
 
99
c int not null,
 
100
primary key(a,b))
 
101
partition by key (a+2)
 
102
partitions 3
 
103
(partition x1 tablespace ts1,
 
104
 partition x2 tablespace ts2,
 
105
 partition x3 tablespace ts3);
 
106
 
 
107
#
 
108
# Partition by key, no partition name
 
109
#
 
110
--error 1064
 
111
CREATE TABLE t1 (
 
112
a int not null,
 
113
b int not null,
 
114
c int not null,
 
115
primary key(a,b))
 
116
partition by key (a)
 
117
partitions 3
 
118
(partition tablespace ts1,
 
119
 partition x2 tablespace ts2,
 
120
 partition x3 tablespace ts3);
 
121
 
 
122
#
 
123
# Partition by key, invalid field in field list
 
124
#
 
125
--error ER_FIELD_NOT_FOUND_PART_ERROR
 
126
CREATE TABLE t1 (
 
127
a int not null,
 
128
b int not null,
 
129
c int not null,
 
130
primary key(a,b))
 
131
partition by key (a,d)
 
132
partitions 3
 
133
(partition x1 tablespace ts1,
 
134
 partition x2 tablespace ts2,
 
135
 partition x3 tablespace ts3);
 
136
 
 
137
let $MYSQLD_DATADIR= `select @@datadir`;
 
138
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
139
#
 
140
# Partition by hash, invalid field in function
 
141
#
 
142
--error 1054
 
143
CREATE TABLE t1 (
 
144
a int not null,
 
145
b int not null,
 
146
c int not null,
 
147
primary key(a,b))
 
148
partition by hash (a + d)
 
149
partitions 3
 
150
(partition x1 tablespace ts1,
 
151
 partition x2 tablespace ts2,
 
152
 partition x3 tablespace ts3);
 
153
 
 
154
#
 
155
# Partition by hash, invalid result type
 
156
#
 
157
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
158
CREATE TABLE t1 (
 
159
a int not null,
 
160
b int not null,
 
161
c int not null,
 
162
primary key(a,b))
 
163
partition by hash (sin(a))
 
164
partitions 3
 
165
(partition x1 tablespace ts1,
 
166
 partition x2 tablespace ts2,
 
167
 partition x3 tablespace ts3);
 
168
 
 
169
#
 
170
# Partition by key specified 3 partitions but only defined 2 => error
 
171
#
 
172
--error 1064
 
173
CREATE TABLE t1 (
 
174
a int not null,
 
175
b int not null,
 
176
c int not null,
 
177
primary key(a,b))
 
178
partition by key (a)
 
179
partitions 3
 
180
(partition x1, partition x2);
 
181
 
 
182
#
 
183
# Partition by key specified 3 partitions but only defined 2 => error
 
184
#
 
185
--error 1064
 
186
CREATE TABLE t1 (
 
187
a int not null,
 
188
b int not null,
 
189
c int not null,
 
190
primary key(a,b))
 
191
partition by hash (rand(a))
 
192
partitions 2
 
193
(partition x1, partition x2);
 
194
 
 
195
#
 
196
# Partition by key specified 3 partitions but only defined 2 => error
 
197
#
 
198
--error 1064
 
199
CREATE TABLE t1 (
 
200
a int not null,
 
201
b int not null,
 
202
c int not null,
 
203
primary key(a,b))
 
204
partition by range (rand(a))
 
205
partitions 2
 
206
(partition x1 values less than (0), partition x2 values less than (2));
 
207
 
 
208
#
 
209
# Partition by key specified 3 partitions but only defined 2 => error
 
210
#
 
211
--error 1064
 
212
CREATE TABLE t1 (
 
213
a int not null,
 
214
b int not null,
 
215
c int not null,
 
216
primary key(a,b))
 
217
partition by list (rand(a))
 
218
partitions 2
 
219
(partition x1 values in (1), partition x2 values in (2));
 
220
 
 
221
#
 
222
# Partition by hash, values less than error
 
223
#
 
224
--error ER_PARTITION_WRONG_VALUES_ERROR
 
225
CREATE TABLE t1 (
 
226
a int not null,
 
227
b int not null,
 
228
c int not null,
 
229
primary key(a,b))
 
230
partition by hash (a)
 
231
partitions 2
 
232
(partition x1 values less than (4),
 
233
 partition x2 values less than (5));
 
234
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
235
 
 
236
#
 
237
# Partition by hash, values in error
 
238
#
 
239
--error ER_PARTITION_WRONG_VALUES_ERROR
 
240
CREATE TABLE t1 (
 
241
a int not null,
 
242
b int not null,
 
243
c int not null,
 
244
primary key(a,b))
 
245
partition by hash (a)
 
246
partitions 2
 
247
(partition x1 values in (4),
 
248
 partition x2 values in (5));
 
249
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
250
 
 
251
#
 
252
# Partition by hash, values in error
 
253
#
 
254
--error ER_PARTITION_WRONG_VALUES_ERROR
 
255
CREATE TABLE t1 (
 
256
a int not null,
 
257
b int not null,
 
258
c int not null,
 
259
primary key(a,b))
 
260
partition by hash (a)
 
261
partitions 2
 
262
(partition x1 values in (4,6),
 
263
 partition x2 values in (5,7));
 
264
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
265
 
 
266
#
 
267
# Subpartition by key, no partitions defined, single field
 
268
#
 
269
--error ER_SUBPARTITION_ERROR
 
270
CREATE TABLE t1 (
 
271
a int not null,
 
272
b int not null,
 
273
c int not null,
 
274
primary key (a,b))
 
275
partition by key (a)
 
276
subpartition by key (b);
 
277
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
278
 
 
279
#
 
280
# Subpartition by key, no partitions defined, list of fields
 
281
#
 
282
--error ER_SUBPARTITION_ERROR
 
283
CREATE TABLE t1 (
 
284
a int not null,
 
285
b int not null,
 
286
c int not null,
 
287
primary key (a,b))
 
288
partition by key (a)
 
289
subpartition by key (a, b);
 
290
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
291
 
 
292
#
 
293
# Subpartition by hash, no partitions defined
 
294
#
 
295
--error ER_SUBPARTITION_ERROR
 
296
CREATE TABLE t1 (
 
297
a int not null,
 
298
b int not null,
 
299
c int not null,
 
300
primary key (a,b))
 
301
partition by key (a)
 
302
subpartition by hash (a+b);
 
303
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
304
 
 
305
#
 
306
# Subpartition by key, no partitions defined, single field
 
307
#
 
308
--error ER_SUBPARTITION_ERROR
 
309
CREATE TABLE t1 (
 
310
a int not null,
 
311
b int not null,
 
312
c int not null,
 
313
primary key (a,b))
 
314
partition by key (a)
 
315
subpartition by key (b);
 
316
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
317
 
 
318
#
 
319
# Subpartition by key, no partitions defined, list of fields
 
320
#
 
321
--error ER_SUBPARTITION_ERROR
 
322
CREATE TABLE t1 (
 
323
a int not null,
 
324
b int not null,
 
325
c int not null,
 
326
primary key (a,b))
 
327
partition by key (a)
 
328
subpartition by key (a, b);
 
329
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
330
 
 
331
#
 
332
# Subpartition by hash, no partitions defined
 
333
#
 
334
--error ER_SUBPARTITION_ERROR
 
335
CREATE TABLE t1 (
 
336
a int not null,
 
337
b int not null,
 
338
c int not null,
 
339
primary key (a,b))
 
340
partition by key (a)
 
341
subpartition by hash (a+b);
 
342
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
343
 
 
344
#
 
345
# Subpartition by hash, no partitions defined, wrong subpartition function
 
346
#
 
347
--error 1064
 
348
CREATE TABLE t1 (
 
349
a int not null,
 
350
b int not null,
 
351
c int not null,
 
352
primary key (a,b))
 
353
partition by key (a)
 
354
subpartition by hash (rand(a+b));
 
355
 
 
356
#
 
357
# Subpartition by hash, wrong subpartition function
 
358
#
 
359
--error ER_SUBPARTITION_ERROR
 
360
CREATE TABLE t1 (
 
361
a int not null,
 
362
b int not null,
 
363
c int not null,
 
364
primary key (a,b))
 
365
partition by key (a)
 
366
subpartition by hash (sin(a+b))
 
367
(partition x1 (subpartition x11, subpartition x12),
 
368
 partition x2 (subpartition x21, subpartition x22));
 
369
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
370
 
 
371
#
 
372
# Subpartition by hash, no partitions defined, wrong subpartition function
 
373
#
 
374
--error 1064
 
375
CREATE TABLE t1 (
 
376
a int not null,
 
377
b int not null,
 
378
c int not null,
 
379
primary key (a,b))
 
380
partition by range (a)
 
381
subpartition by key (a+b)
 
382
(partition x1 values less than (1) (subpartition x11, subpartition x12),
 
383
 partition x2 values less than (2) (subpartition x21, subpartition x22));
 
384
 
 
385
#
 
386
# Subpartition by hash, no partitions defined, wrong subpartition function
 
387
#
 
388
--error ER_FIELD_NOT_FOUND_PART_ERROR
 
389
CREATE TABLE t1 (
 
390
a int not null,
 
391
b int not null,
 
392
c int not null,
 
393
primary key (a,b))
 
394
partition by range (a)
 
395
subpartition by key (a,d)
 
396
(partition x1 values less than (1) (subpartition x11, subpartition x12),
 
397
 partition x2 values less than (2) (subpartition x21, subpartition x22));
 
398
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
399
 
 
400
#
 
401
# Subpartition by hash, no partitions defined, wrong subpartition function
 
402
#
 
403
--error ER_SUBPARTITION_ERROR
 
404
CREATE TABLE t1 (
 
405
a int not null,
 
406
b int not null,
 
407
c int not null,
 
408
primary key (a,b))
 
409
partition by key (a)
 
410
subpartition by hash (3+4);
 
411
 
 
412
#
 
413
# Subpartition by hash, no partitions defined, wrong subpartition function
 
414
#
 
415
--error 1054
 
416
CREATE TABLE t1 (
 
417
a int not null,
 
418
b int not null,
 
419
c int not null,
 
420
primary key (a,b))
 
421
partition by range (a)
 
422
subpartition by hash (a+d)
 
423
(partition x1 values less than (1) (subpartition x11, subpartition x12),
 
424
 partition x2 values less than (2) (subpartition x21, subpartition x22));
 
425
 
 
426
#
 
427
# Partition by range, no partition => error
 
428
#
 
429
--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
 
430
CREATE TABLE t1 (
 
431
a int not null,
 
432
b int not null,
 
433
c int not null,
 
434
primary key(a,b))
 
435
partition by range (a);
 
436
select load_file('$MYSQLD_DATADIR/test/t1.par');
 
437
 
 
438
#
 
439
# Partition by range, invalid field in function
 
440
#
 
441
--error 1054
 
442
CREATE TABLE t1 (
 
443
a int not null,
 
444
b int not null,
 
445
c int not null,
 
446
primary key(a,b))
 
447
partition by range (a+d)
 
448
partitions 2
 
449
(partition x1 values less than (4) tablespace ts1,
 
450
 partition x2 values less than (8) tablespace ts2);
 
451
 
 
452
#
 
453
# Partition by range, inconsistent partition function and constants
 
454
#
 
455
--error 1064
 
456
CREATE TABLE t1 (
 
457
a int not null,
 
458
b int not null,
 
459
c int not null,
 
460
primary key(a,b))
 
461
partition by range (a)
 
462
partitions 2
 
463
(partition x1 values less than (4.0) tablespace ts1,
 
464
 partition x2 values less than (8) tablespace ts2);
 
465
 
 
466
#
 
467
# Partition by range, constant partition function not allowed
 
468
#
 
469
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
470
CREATE TABLE t1 (
 
471
a int not null,
 
472
b int not null,
 
473
c int not null,
 
474
primary key(a,b))
 
475
partition by range (3+4)
 
476
partitions 2
 
477
(partition x1 values less than (4) tablespace ts1,
 
478
 partition x2 values less than (8) tablespace ts2);
 
479
 
 
480
 
481
# Partition by range, no values less than definition
 
482
 
483
--error ER_PARTITION_REQUIRES_VALUES_ERROR
 
484
CREATE TABLE t1 ( 
 
485
a int not null,
 
486
b int not null,
 
487
c int not null,
 
488
primary key(a,b))
 
489
partition by range (a)
 
490
partitions 2
 
491
(partition x1 values less than (4),
 
492
 partition x2); 
 
493
 
 
494
#
 
495
# Partition by range, no values in definition allowed
 
496
#
 
497
--error ER_PARTITION_WRONG_VALUES_ERROR
 
498
CREATE TABLE t1 (
 
499
a int not null,
 
500
b int not null,
 
501
c int not null,
 
502
primary key(a,b))
 
503
partition by range (a)
 
504
partitions 2
 
505
(partition x1 values in (4),
 
506
 partition x2);
 
507
 
 
508
#
 
509
# Partition by range, values in error
 
510
#
 
511
--error ER_PARTITION_WRONG_VALUES_ERROR
 
512
CREATE TABLE t1 (
 
513
a int not null,
 
514
b int not null,
 
515
c int not null,
 
516
primary key(a,b))
 
517
partition by range (a)
 
518
partitions 2
 
519
(partition x1 values in (4),
 
520
 partition x2 values less than (5));
 
521
 
 
522
#
 
523
# Partition by range, missing parenthesis
 
524
#
 
525
--error 1064
 
526
CREATE TABLE t1 (
 
527
a int not null,
 
528
b int not null,
 
529
c int not null,
 
530
primary key(a,b))
 
531
partition by list (a)
 
532
partitions 2
 
533
(partition x1 values less than 4,
 
534
 partition x2 values less than (5));
 
535
 
 
536
#
 
537
# Partition by range, maxvalue in wrong place
 
538
#
 
539
--error 1064
 
540
CREATE TABLE t1 (
 
541
a int not null,
 
542
b int not null,
 
543
c int not null,
 
544
primary key(a,b))
 
545
partition by range (a)
 
546
partitions 2
 
547
(partition x1 values less than maxvalue,
 
548
 partition x2 values less than (5));
 
549
 
 
550
#
 
551
# Partition by range, maxvalue in several places
 
552
#
 
553
--error 1064
 
554
CREATE TABLE t1 (
 
555
a int not null,
 
556
b int not null,
 
557
c int not null,
 
558
primary key(a,b))
 
559
partition by range (a)
 
560
partitions 2
 
561
(partition x1 values less than maxvalue,
 
562
 partition x2 values less than maxvalue);
 
563
 
 
564
#
 
565
# Partition by range, not increasing ranges
 
566
#
 
567
--error ER_RANGE_NOT_INCREASING_ERROR
 
568
CREATE TABLE t1 (
 
569
a int not null,
 
570
b int not null,
 
571
c int not null,
 
572
primary key(a,b))
 
573
partition by range (a)
 
574
partitions 2
 
575
(partition x1 values less than (4),
 
576
 partition x2 values less than (3));
 
577
 
 
578
#
 
579
# Partition by range, wrong result type of partition function
 
580
#
 
581
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
582
CREATE TABLE t1 (
 
583
a int not null,
 
584
b int not null,
 
585
c int not null,
 
586
primary key(a,b))
 
587
partition by range (sin(a))
 
588
partitions 2
 
589
(partition x1 values less than (4),
 
590
 partition x2 values less than (5));
 
591
 
 
592
#
 
593
# Subpartition by hash, wrong number of subpartitions
 
594
#
 
595
--error 1064
 
596
CREATE TABLE t1 (
 
597
a int not null,
 
598
b int not null,
 
599
c int not null,
 
600
primary key (a,b))
 
601
partition by list (a)
 
602
subpartition by hash (a+b)
 
603
subpartitions 3
 
604
( partition x1 values in (1,2,4)
 
605
  ( subpartition x11 nodegroup 0,
 
606
    subpartition x12 nodegroup 1),
 
607
  partition x2 values in (3,5,6)
 
608
  ( subpartition x21 nodegroup 0,
 
609
    subpartition x22 nodegroup 1)
 
610
);
 
611
 
 
612
#
 
613
# Subpartition by hash, wrong number of subpartitions
 
614
#
 
615
--error 1064
 
616
CREATE TABLE t1 (
 
617
a int not null,
 
618
b int not null,
 
619
c int not null,
 
620
primary key (a,b))
 
621
partition by list (a)
 
622
subpartition by hash (a+b)
 
623
( partition x1 values in (1)
 
624
  ( subpartition x11 nodegroup 0,
 
625
    subpartition xextra,
 
626
    subpartition x12 nodegroup 1),
 
627
  partition x2 values in (2)
 
628
  ( subpartition x21 nodegroup 0,
 
629
    subpartition x22 nodegroup 1)
 
630
);
 
631
 
 
632
#
 
633
# Subpartition by list => error
 
634
#
 
635
--error 1064 
 
636
CREATE TABLE t1 (
 
637
a int not null,
 
638
b int not null,
 
639
c int not null,
 
640
primary key (a,b))
 
641
partition by key (a) 
 
642
subpartition by list (a+b)
 
643
( partition x1
 
644
  ( subpartition x11 engine myisam,
 
645
    subpartition x12 engine myisam),
 
646
   partition x2 
 
647
   ( subpartition x21 engine myisam,
 
648
     subpartition x22 engine myisam)
 
649
);
 
650
 
 
651
#
 
652
# Subpartition by list => error
 
653
#
 
654
--error 1064
 
655
CREATE TABLE t1 (
 
656
a int not null,
 
657
b int not null,
 
658
c int not null,
 
659
primary key (a,b))
 
660
partition by key (a)
 
661
subpartition by list (a+b)
 
662
( partition x1
 
663
  ( subpartition x11 engine myisam values in (0),
 
664
    subpartition x12 engine myisam values in (1)),
 
665
  partition x2
 
666
  ( subpartition x21 engine myisam values in (0),
 
667
    subpartition x22 engine myisam values in (1))
 
668
);
 
669
 
 
670
#
 
671
# Partition by list, no partition => error
 
672
#
 
673
--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
 
674
CREATE TABLE t1 (
 
675
a int not null,
 
676
b int not null,
 
677
c int not null,
 
678
primary key(a,b))
 
679
partition by list (a);
 
680
 
 
681
#
 
682
# Partition by list, constant partition function not allowed
 
683
#
 
684
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
685
CREATE TABLE t1 (
 
686
a int not null,
 
687
b int not null,
 
688
c int not null,
 
689
primary key(a,b))
 
690
partition by list (3+4)
 
691
partitions 2 
 
692
(partition x1 values in (4) tablespace ts1,
 
693
 partition x2 values in (8) tablespace ts2);
 
694
 
 
695
#
 
696
# Partition by list, invalid field in function
 
697
#
 
698
--error 1054
 
699
CREATE TABLE t1 (
 
700
a int not null,
 
701
b int not null,
 
702
c int not null,
 
703
primary key(a,b))
 
704
partition by list (a+d)
 
705
partitions 2
 
706
(partition x1 values in (4) tablespace ts1,
 
707
 partition x2 values in (8) tablespace ts2);
 
708
 
 
709
 
710
# Partition by list, no values in definition
 
711
 
712
--error ER_PARTITION_REQUIRES_VALUES_ERROR
 
713
CREATE TABLE t1 (
 
714
a int not null,
 
715
b int not null,
 
716
c int not null,
 
717
primary key(a,b))
 
718
partition by list (a)
 
719
partitions 2
 
720
(partition x1 values in (4),
 
721
 partition x2);
 
722
 
 
723
#
 
724
# Partition by list, values less than error
 
725
#
 
726
--error ER_PARTITION_WRONG_VALUES_ERROR
 
727
CREATE TABLE t1 (
 
728
a int not null,
 
729
b int not null,
 
730
c int not null,
 
731
primary key(a,b))
 
732
partition by list (a)
 
733
partitions 2
 
734
(partition x1 values in (4),
 
735
 partition x2 values less than (5));
 
736
 
 
737
#
 
738
# Partition by list, no values in definition
 
739
#
 
740
--error ER_PARTITION_REQUIRES_VALUES_ERROR
 
741
CREATE TABLE t1 (
 
742
a int not null,
 
743
b int not null,
 
744
c int not null,
 
745
primary key(a,b))
 
746
partition by list (a)
 
747
partitions 2
 
748
(partition x1 values in (4,6),
 
749
 partition x2);
 
750
 
 
751
#
 
752
# Partition by list, duplicate values
 
753
#
 
754
--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
 
755
CREATE TABLE t1 (
 
756
a int not null,
 
757
b int not null,
 
758
c int not null,
 
759
primary key(a,b))
 
760
partition by list (a)
 
761
partitions 2
 
762
(partition x1 values in (4, 12+9),
 
763
 partition x2 values in (3, 21));
 
764
 
 
765
#
 
766
# Partition by list, wrong constant result type (not INT)
 
767
#
 
768
--error 1064
 
769
CREATE TABLE t1 (
 
770
a int not null,
 
771
b int not null,
 
772
c int not null,
 
773
primary key(a,b))
 
774
partition by list (a)
 
775
partitions 2
 
776
(partition x1 values in (4.0, 12+8),
 
777
 partition x2 values in (3, 21));
 
778
 
 
779
#
 
780
# Partition by list, missing parenthesis
 
781
#
 
782
--error 1064
 
783
CREATE TABLE t1 (
 
784
a int not null,
 
785
b int not null,
 
786
c int not null,
 
787
primary key(a,b))
 
788
partition by list (a)
 
789
partitions 2
 
790
(partition x1 values in 4,
 
791
 partition x2 values in (5));
 
792
 
 
793
#
 
794
# Bug #13439: Crash when LESS THAN (non-literal)
 
795
#
 
796
--error 1054
 
797
CREATE TABLE t1 (a int)
 
798
PARTITION BY RANGE (a)
 
799
(PARTITION p0 VALUES LESS THAN (x1));
 
800
 
 
801
#
 
802
# No partition for the given value
 
803
#
 
804
CREATE TABLE t1(a int)
 
805
  PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN(5));
 
806
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
 
807
insert into t1 values (10);
 
808
drop table t1;
 
809
 
 
810
--error ER_PARTITION_CONST_DOMAIN_ERROR
 
811
create table t1 (a bigint unsigned)
 
812
partition by range (a)
 
813
(partition p0 values less than (-1));
 
814
#
 
815
# Bug 18198 Partitions: Verify that erroneus partition functions doesn't work
 
816
#
 
817
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
818
create table t1 (v varchar(12))
 
819
partition by range (ascii(v))
 
820
(partition p0 values less than (10));
 
821
#drop table t1;
 
822
 
 
823
-- error 1064
 
824
create table t1 (a int)
 
825
partition by hash (rand(a));
 
826
-- error 1064
 
827
create table t1 (a int)
 
828
partition by hash(CURTIME() + a);
 
829
-- error 1064
 
830
create table t1 (a int)
 
831
partition by hash (NOW()+a);
 
832
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
833
create table t1 (a int)
 
834
partition by hash (extract(hour from convert_tz(a, '+00:00', '+00:00')));
 
835
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
836
create table t1 (a int)
 
837
partition by range (a + (select count(*) from t1))
 
838
(partition p1 values less than (1));
 
839
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 
840
create table t1 (a char(10))
 
841
partition by hash (extractvalue(a,'a'));
 
842
 
 
843
--echo #
 
844
--echo # Bug #42849: innodb crash with varying time_zone on partitioned
 
845
--echo #             timestamp primary key
 
846
--echo #
 
847
 
 
848
# A correctly partitioned table to test that trying to repartition it using
 
849
# timezone-dependent expression will throw an error.
 
850
CREATE TABLE old (a TIMESTAMP NOT NULL PRIMARY KEY)
 
851
PARTITION BY RANGE (UNIX_TIMESTAMP(a)) (
 
852
PARTITION p VALUES LESS THAN (1219089600),
 
853
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
854
 
 
855
# Check that allowed arithmetic/math functions involving TIMESTAMP values result
 
856
# in ER_PARTITION_FUNC_NOT_ALLOWED_ERROR when used as a partitioning function
 
857
 
 
858
--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
 
859
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
860
PARTITION BY RANGE (a) (
 
861
PARTITION p VALUES LESS THAN (20080819),
 
862
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
863
 
 
864
--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
 
865
ALTER TABLE old
 
866
PARTITION BY RANGE (a) (
 
867
PARTITION p VALUES LESS THAN (20080819),
 
868
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
869
 
 
870
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
871
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
872
PARTITION BY RANGE (a+0) (
 
873
PARTITION p VALUES LESS THAN (20080819),
 
874
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
875
 
 
876
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
877
ALTER TABLE old
 
878
PARTITION BY RANGE (a+0) (
 
879
PARTITION p VALUES LESS THAN (20080819),
 
880
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
881
 
 
882
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
883
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
884
PARTITION BY RANGE (a % 2) (
 
885
PARTITION p VALUES LESS THAN (20080819),
 
886
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
887
 
 
888
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
889
ALTER TABLE old
 
890
PARTITION BY RANGE (a % 2) (
 
891
PARTITION p VALUES LESS THAN (20080819),
 
892
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
893
 
 
894
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
895
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
896
PARTITION BY RANGE (ABS(a)) (
 
897
PARTITION p VALUES LESS THAN (20080819),
 
898
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
899
 
 
900
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
901
ALTER TABLE old
 
902
PARTITION BY RANGE (ABS(a)) (
 
903
PARTITION p VALUES LESS THAN (20080819),
 
904
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
905
 
 
906
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
907
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
908
PARTITION BY RANGE (CEILING(a)) (
 
909
PARTITION p VALUES LESS THAN (20080819),
 
910
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
911
 
 
912
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
913
ALTER TABLE old
 
914
PARTITION BY RANGE (CEILING(a)) (
 
915
PARTITION p VALUES LESS THAN (20080819),
 
916
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
917
 
 
918
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
919
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
920
PARTITION BY RANGE (FLOOR(a)) (
 
921
PARTITION p VALUES LESS THAN (20080819),
 
922
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
923
 
 
924
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
925
ALTER TABLE old
 
926
PARTITION BY RANGE (FLOOR(a)) (
 
927
PARTITION p VALUES LESS THAN (20080819),
 
928
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
929
 
 
930
# Check that allowed date/time functions involving TIMESTAMP values result
 
931
# in ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR when used as a partitioning function
 
932
 
 
933
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
934
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
935
PARTITION BY RANGE (TO_DAYS(a)) (
 
936
PARTITION p VALUES LESS THAN (733638),
 
937
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
938
 
 
939
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
940
ALTER TABLE old
 
941
PARTITION BY RANGE (TO_DAYS(a)) (
 
942
PARTITION p VALUES LESS THAN (733638),
 
943
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
944
 
 
945
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
946
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
947
PARTITION BY RANGE (DAYOFYEAR(a)) (
 
948
PARTITION p VALUES LESS THAN (231),
 
949
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
950
 
 
951
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
952
ALTER TABLE old
 
953
PARTITION BY RANGE (DAYOFYEAR(a)) (
 
954
PARTITION p VALUES LESS THAN (231),
 
955
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
956
 
 
957
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
958
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
959
PARTITION BY RANGE (DAYOFMONTH(a)) (
 
960
PARTITION p VALUES LESS THAN (19),
 
961
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
962
 
 
963
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
964
ALTER TABLE old
 
965
PARTITION BY RANGE (DAYOFMONTH(a)) (
 
966
PARTITION p VALUES LESS THAN (19),
 
967
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
968
 
 
969
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
970
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
971
PARTITION BY RANGE (DAYOFWEEK(a)) (
 
972
PARTITION p VALUES LESS THAN (3),
 
973
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
974
 
 
975
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
976
ALTER TABLE old
 
977
PARTITION BY RANGE (DAYOFWEEK(a)) (
 
978
PARTITION p VALUES LESS THAN (3),
 
979
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
980
 
 
981
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
982
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
983
PARTITION BY RANGE (MONTH(a)) (
 
984
PARTITION p VALUES LESS THAN (8),
 
985
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
986
 
 
987
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
988
ALTER TABLE old
 
989
PARTITION BY RANGE (MONTH(a)) (
 
990
PARTITION p VALUES LESS THAN (8),
 
991
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
992
 
 
993
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
994
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
995
PARTITION BY RANGE (HOUR(a)) (
 
996
PARTITION p VALUES LESS THAN (17),
 
997
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
998
 
 
999
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1000
ALTER TABLE old
 
1001
PARTITION BY RANGE (HOUR(a)) (
 
1002
PARTITION p VALUES LESS THAN (17),
 
1003
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1004
 
 
1005
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1006
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1007
PARTITION BY RANGE (MINUTE(a)) (
 
1008
PARTITION p VALUES LESS THAN (55),
 
1009
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1010
 
 
1011
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1012
ALTER TABLE old
 
1013
PARTITION BY RANGE (MINUTE(a)) (
 
1014
PARTITION p VALUES LESS THAN (55),
 
1015
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1016
 
 
1017
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1018
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1019
PARTITION BY RANGE (QUARTER(a)) (
 
1020
PARTITION p VALUES LESS THAN (3),
 
1021
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1022
 
 
1023
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1024
ALTER TABLE old
 
1025
PARTITION BY RANGE (QUARTER(a)) (
 
1026
PARTITION p VALUES LESS THAN (3),
 
1027
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1028
 
 
1029
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1030
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1031
PARTITION BY RANGE (SECOND(a)) (
 
1032
PARTITION p VALUES LESS THAN (7),
 
1033
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1034
 
 
1035
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1036
ALTER TABLE old
 
1037
PARTITION BY RANGE (SECOND(a)) (
 
1038
PARTITION p VALUES LESS THAN (7),
 
1039
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1040
 
 
1041
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1042
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1043
PARTITION BY RANGE (YEARWEEK(a)) (
 
1044
PARTITION p VALUES LESS THAN (200833),
 
1045
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1046
 
 
1047
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1048
ALTER TABLE old
 
1049
PARTITION BY RANGE (YEARWEEK(a)) (
 
1050
PARTITION p VALUES LESS THAN (200833),
 
1051
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1052
 
 
1053
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1054
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1055
PARTITION BY RANGE (YEAR(a)) (
 
1056
PARTITION p VALUES LESS THAN (2008),
 
1057
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1058
 
 
1059
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1060
ALTER TABLE old
 
1061
PARTITION BY RANGE (YEAR(a)) (
 
1062
PARTITION p VALUES LESS THAN (2008),
 
1063
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1064
 
 
1065
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1066
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1067
PARTITION BY RANGE (WEEKDAY(a)) (
 
1068
PARTITION p VALUES LESS THAN (3),
 
1069
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1070
 
 
1071
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1072
ALTER TABLE old
 
1073
PARTITION BY RANGE (WEEKDAY(a)) (
 
1074
PARTITION p VALUES LESS THAN (3),
 
1075
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1076
 
 
1077
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1078
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1079
PARTITION BY RANGE (TIME_TO_SEC(a)) (
 
1080
PARTITION p VALUES LESS THAN (64507),
 
1081
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1082
 
 
1083
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1084
ALTER TABLE old
 
1085
PARTITION BY RANGE (TIME_TO_SEC(a)) (
 
1086
PARTITION p VALUES LESS THAN (64507),
 
1087
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1088
 
 
1089
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1090
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1091
PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
 
1092
PARTITION p VALUES LESS THAN (18),
 
1093
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1094
 
 
1095
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1096
ALTER TABLE old
 
1097
PARTITION BY RANGE (EXTRACT(DAY FROM a)) (
 
1098
PARTITION p VALUES LESS THAN (18),
 
1099
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1100
 
 
1101
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1102
CREATE TABLE new (a TIMESTAMP NOT NULL, b TIMESTAMP NOT NULL, PRIMARY KEY(a,b))
 
1103
PARTITION BY RANGE (DATEDIFF(a, a)) (
 
1104
PARTITION p VALUES LESS THAN (18),
 
1105
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1106
 
 
1107
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1108
ALTER TABLE old
 
1109
PARTITION BY RANGE (DATEDIFF(a, a)) (
 
1110
PARTITION p VALUES LESS THAN (18),
 
1111
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1112
 
 
1113
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1114
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1115
PARTITION BY RANGE (YEAR(a + 0)) (
 
1116
PARTITION p VALUES LESS THAN (2008),
 
1117
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1118
 
 
1119
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1120
ALTER TABLE old
 
1121
PARTITION BY RANGE (YEAR(a + 0)) (
 
1122
PARTITION p VALUES LESS THAN (2008),
 
1123
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1124
 
 
1125
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1126
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1127
PARTITION BY RANGE (TO_DAYS(a + '2008-01-01')) (
 
1128
PARTITION p VALUES LESS THAN (733638),
 
1129
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1130
 
 
1131
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1132
ALTER TABLE old
 
1133
PARTITION BY RANGE (TO_DAYS(a + '2008-01-01')) (
 
1134
PARTITION p VALUES LESS THAN (733638),
 
1135
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1136
 
 
1137
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1138
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
 
1139
PARTITION BY RANGE (YEAR(a + '2008-01-01')) (
 
1140
PARTITION p VALUES LESS THAN (2008),
 
1141
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1142
 
 
1143
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1144
ALTER TABLE old
 
1145
PARTITION BY RANGE (YEAR(a + '2008-01-01')) (
 
1146
PARTITION p VALUES LESS THAN (2008),
 
1147
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1148
 
 
1149
ALTER TABLE old ADD COLUMN b DATE;
 
1150
 
 
1151
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1152
CREATE TABLE new (a TIMESTAMP, b DATE)
 
1153
PARTITION BY RANGE (YEAR(a + b)) (
 
1154
PARTITION p VALUES LESS THAN (2008),
 
1155
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1156
 
 
1157
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1158
ALTER TABLE old
 
1159
PARTITION BY RANGE (YEAR(a + b)) (
 
1160
PARTITION p VALUES LESS THAN (2008),
 
1161
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1162
 
 
1163
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1164
CREATE TABLE new (a TIMESTAMP, b DATE)
 
1165
PARTITION BY RANGE (TO_DAYS(a + b)) (
 
1166
PARTITION p VALUES LESS THAN (733638),
 
1167
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1168
 
 
1169
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1170
ALTER TABLE old
 
1171
PARTITION BY RANGE (TO_DAYS(a + b)) (
 
1172
PARTITION p VALUES LESS THAN (733638),
 
1173
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1174
 
 
1175
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1176
CREATE TABLE new (a TIMESTAMP, b date)
 
1177
PARTITION BY RANGE (UNIX_TIMESTAMP(a + b)) (
 
1178
PARTITION p VALUES LESS THAN (1219089600),
 
1179
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1180
 
 
1181
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1182
ALTER TABLE old
 
1183
PARTITION BY RANGE (UNIX_TIMESTAMP(a + b)) (
 
1184
PARTITION p VALUES LESS THAN (1219089600),
 
1185
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1186
 
 
1187
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1188
CREATE TABLE new (a TIMESTAMP, b TIMESTAMP)
 
1189
PARTITION BY RANGE (UNIX_TIMESTAMP(a + b)) (
 
1190
PARTITION p VALUES LESS THAN (1219089600),
 
1191
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1192
 
 
1193
ALTER TABLE old MODIFY b TIMESTAMP;
 
1194
 
 
1195
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
 
1196
ALTER TABLE old
 
1197
PARTITION BY RANGE (UNIX_TIMESTAMP(a + b)) (
 
1198
PARTITION p VALUES LESS THAN (1219089600),
 
1199
PARTITION pmax VALUES LESS THAN MAXVALUE);
 
1200
 
 
1201
DROP TABLE old;
 
1202
 
 
1203
--echo End of 5.1 tests