line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Partition::Type::Range; |
2
|
1
|
|
|
1
|
|
867
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
197
|
|
3
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
74
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use parent 'MySQL::Partition'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
7
|
1
|
|
|
|
|
10
|
ro => [qw/catch_all_partition_name/], |
8
|
1
|
|
|
1
|
|
74
|
); |
|
1
|
|
|
|
|
3
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->_grow_methods(qw/add_catch_all_partition reorganize_catch_all_partition/); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _build_add_catch_all_partition_sql { |
13
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
14
|
1
|
50
|
|
|
|
5
|
die "catch_all_partition_name isn't specified" unless $self->catch_all_partition_name; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
12
|
sprintf 'ALTER TABLE %s ADD PARTITION (%s)', |
17
|
|
|
|
|
|
|
$self->table, $self->_build_partition_part($self->catch_all_partition_name, 'MAXVALUE'); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _build_reorganize_catch_all_partition_sql { |
21
|
1
|
|
|
1
|
|
4
|
my ($self, @args) = @_; |
22
|
1
|
50
|
|
|
|
4
|
die "catch_all_partition_name isn't specified" unless $self->catch_all_partition_name; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
11
|
sprintf 'ALTER TABLE %s REORGANIZE PARTITION %s INTO (%s, PARTITION %s VALUES LESS THAN (MAXVALUE))', |
25
|
|
|
|
|
|
|
$self->table, $self->catch_all_partition_name, $self->_build_partition_parts(@args), $self->catch_all_partition_name; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _build_partition_part { |
29
|
8
|
|
|
8
|
|
29
|
my ($self, $partition_name, $partition_description) = @_; |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
9
|
my $comment; |
32
|
8
|
100
|
66
|
|
|
27
|
if (ref $partition_description && ref $partition_description eq 'HASH') { |
33
|
1
|
|
|
|
|
3
|
$comment = $partition_description->{comment}; |
34
|
1
|
50
|
|
|
|
5
|
$comment =~ s/'//g if defined $comment; |
35
|
1
|
|
|
|
|
2
|
$partition_description = $partition_description->{description}; |
36
|
1
|
50
|
|
|
|
4
|
die 'no partition_description is specified' unless $partition_description; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
8
|
100
|
100
|
|
|
74
|
if ($partition_description !~ /^[0-9]+$/ && $partition_description ne 'MAXVALUE' && $partition_description !~ /\(/) { |
|
|
|
100
|
|
|
|
|
40
|
3
|
|
|
|
|
6
|
$partition_description = "'$partition_description'"; |
41
|
|
|
|
|
|
|
} |
42
|
8
|
|
|
|
|
34
|
my $part = sprintf 'PARTITION %s VALUES LESS THAN (%s)', $partition_name, $partition_description; |
43
|
8
|
100
|
|
|
|
36
|
$part .= " COMMENT = '$comment'" if $comment; |
44
|
8
|
|
|
|
|
49
|
$part; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |