class Sequel::Postgres::CreatePartitionOfTableGenerator
Generator used for creating tables that are partitions of other tables.
Constants
- MAXVALUE
- MINVALUE
Public Class Methods
# File lib/sequel/adapters/shared/postgres.rb 142 def initialize(&block) 143 instance_exec(&block) 144 end
Public Instance Methods
Sets that this is a default partition, where values not in other partitions are stored.
# File lib/sequel/adapters/shared/postgres.rb 187 def default 188 @default = true 189 end
Assumes range partitioning, sets the inclusive minimum value of the range for this partition.
# File lib/sequel/adapters/shared/postgres.rb 160 def from(*v) 161 @from = v 162 end
The modulus and remainder to use for this partition for a hash partition.
# File lib/sequel/adapters/shared/postgres.rb 202 def hash_values 203 [@modulus, @remainder] 204 end
The values to include in this partition for a list partition.
# File lib/sequel/adapters/shared/postgres.rb 197 def list 198 @in 199 end
The minimum value of the data type used in range partitions, useful as an argument to to
.
# File lib/sequel/adapters/shared/postgres.rb 154 def maxvalue 155 MAXVALUE 156 end
The minimum value of the data type used in range partitions, useful as an argument to from
.
# File lib/sequel/adapters/shared/postgres.rb 148 def minvalue 149 MINVALUE 150 end
Assumes hash partitioning, sets the modulus for this parition.
# File lib/sequel/adapters/shared/postgres.rb 176 def modulus(v) 177 @modulus = v 178 end
Determine the appropriate partition type for this partition by which methods were called on it.
# File lib/sequel/adapters/shared/postgres.rb 208 def partition_type 209 raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1 210 211 if @from || @to 212 raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to 213 :range 214 elsif @in 215 :list 216 elsif @modulus || @remainder 217 raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder 218 :hash 219 elsif @default 220 :default 221 else 222 raise Error, "unable to determine partition type, no partitioning methods called" 223 end 224 end
The from and to values of this partition for a range partition.
# File lib/sequel/adapters/shared/postgres.rb 192 def range 193 [@from, @to] 194 end
Assumes hash partitioning, sets the remainder for this parition.
# File lib/sequel/adapters/shared/postgres.rb 181 def remainder(v) 182 @remainder = v 183 end
Assumes range partitioning, sets the exclusive maximum value of the range for this partition.
# File lib/sequel/adapters/shared/postgres.rb 166 def to(*v) 167 @to = v 168 end
Assumes list partitioning, sets the values to be included in this partition.
# File lib/sequel/adapters/shared/postgres.rb 171 def values_in(*v) 172 @in = v 173 end