~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to mysql-test/suite/vcol/r/vcol_partition_innodb.result

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
SET @@session.storage_engine = 'InnoDB';
 
2
drop table if exists t1;
 
3
# Case 1. Partitioning by RANGE based on a non-stored virtual column.
 
4
CREATE TABLE t1 (
 
5
a DATE NOT NULL,
 
6
b int as (year(a))
 
7
)
 
8
PARTITION BY RANGE( b ) (
 
9
PARTITION p0 VALUES LESS THAN (2006),
 
10
PARTITION p2 VALUES LESS THAN (2008)
 
11
);
 
12
insert into t1 values ('2006-01-01',default);
 
13
insert into t1 values ('2007-01-01',default);
 
14
insert into t1 values ('2005-01-01',default);
 
15
select * from t1;
 
16
a       b
 
17
2005-01-01      2005
 
18
2006-01-01      2006
 
19
2007-01-01      2007
 
20
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
 
21
partition_name  table_rows      data_length
 
22
p0      1       16384
 
23
p2      2       16384
 
24
# Modify the expression of virtual column b
 
25
ALTER TABLE t1 modify b int as (year(a)-1);
 
26
select * from t1;
 
27
a       b
 
28
2005-01-01      2004
 
29
2006-01-01      2005
 
30
2007-01-01      2006
 
31
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
 
32
partition_name  table_rows      data_length
 
33
p0      2       16384
 
34
p2      1       16384
 
35
drop table t1;
 
36
# Case 2. Partitioning by LIST based on a stored virtual column.
 
37
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
 
38
PARTITION BY LIST (a+1)
 
39
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
 
40
insert into t1 values (1,default);
 
41
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
 
42
partition_name  table_rows      data_length
 
43
p1      0       16384
 
44
p2      1       16384
 
45
select * from t1;
 
46
a       b
 
47
1       1
 
48
select * from t1;
 
49
a       b
 
50
1       1
 
51
drop table t1;
 
52
# Case 3. Partitioning by HASH based on a non-stored virtual column.
 
53
CREATE TABLE t1 (
 
54
a DATE NOT NULL,
 
55
b int as (year(a))
 
56
)
 
57
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
 
58
insert into t1 values ('2005-01-01',default);
 
59
insert into t1 values ('2006-01-01',default);
 
60
select * from t1;
 
61
a       b
 
62
2005-01-01      2005
 
63
2006-01-01      2006
 
64
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
 
65
partition_name  table_rows      data_length
 
66
p0      0       16384
 
67
p1      1       16384
 
68
p2      1       16384
 
69
# Modify the expression of virtual column b
 
70
ALTER TABLE t1 modify b int as (year(a)-1);
 
71
select * from t1;
 
72
a       b
 
73
2005-01-01      2004
 
74
2006-01-01      2005
 
75
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
 
76
partition_name  table_rows      data_length
 
77
p0      1       16384
 
78
p1      1       16384
 
79
p2      0       16384
 
80
drop table t1;