module MysqlPartition::Type::Range
Public Instance Methods
add_catch_all_partition()
click to toggle source
# File lib/mysql_partition/type/range.rb, line 12 def add_catch_all_partition unless catch_all_partition_name raise "catch_all_partition_name isn't specified" end sprintf 'ALTER TABLE %s ADD PARTITION (%s)', table, build_partition_part(catch_all_partition_name, 'MAXVALUE') end
create_partitions(hash)
click to toggle source
Calls superclass method
# File lib/mysql_partition/type/range.rb, line 5 def create_partitions(hash) if catch_all_partition_name hash.merge!(catch_all_partition_name => "MAXVALUE") end super(hash) end
reorganize_catch_all_partition(hash)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 21 def reorganize_catch_all_partition(hash) unless catch_all_partition_name raise "catch_all_partition_name isn't specified" end sprintf 'ALTER TABLE %s REORGANIZE PARTITION %s INTO (%s, PARTITION %s VALUES LESS THAN (MAXVALUE))', table, catch_all_partition_name, build_partition_parts(hash), catch_all_partition_name end
Private Instance Methods
build_partition_part(partition_name, partition_description)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 35 def build_partition_part(partition_name, partition_description) # TODO: support comment, description if string?(partition_description) partition_description = "'#{partition_description}'" end sprintf 'PARTITION %s VALUES LESS THAN (%s)', partition_name, partition_description; end
catch_all_partition_name()
click to toggle source
# File lib/mysql_partition/type/range.rb, line 31 def catch_all_partition_name args[:catch_all_partition_name] end
function?(v)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 57 def function?(v) v =~ /\(/ end
integer?(v)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 49 def integer?(v) v =~ /^[0-9]+$/ end
maxvalue?(v)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 53 def maxvalue?(v) v == 'MAXVALUE' end
string?(v)
click to toggle source
# File lib/mysql_partition/type/range.rb, line 45 def string?(v) !(integer?(v) || maxvalue?(v) || function?(v)) end