class Sequel::Postgres::CreatePartitionOfTableGenerator

  1. lib/sequel/adapters/shared/postgres.rb
Superclass: Object

Generator used for creating tables that are partitions of other tables.

Constants

MAXVALUE = Sequel.lit('MAXVALUE').freeze  
MINVALUE = Sequel.lit('MINVALUE').freeze  

Public Class methods

new(&block)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
174 def initialize(&block)
175   instance_exec(&block)
176 end

Public Instance methods

default()

Sets that this is a default partition, where values not in other partitions are stored.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
219 def default
220   @default = true
221 end
from(*v)

Assumes range partitioning, sets the inclusive minimum value of the range for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
192 def from(*v)
193   @from = v
194 end
hash_values()

The modulus and remainder to use for this partition for a hash partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
234 def hash_values
235   [@modulus, @remainder]
236 end
list()

The values to include in this partition for a list partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
229 def list
230   @in
231 end
maxvalue()

The minimum value of the data type used in range partitions, useful as an argument to to.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
186 def maxvalue
187   MAXVALUE
188 end
minvalue()

The minimum value of the data type used in range partitions, useful as an argument to from.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
180 def minvalue
181   MINVALUE
182 end
modulus(v)

Assumes hash partitioning, sets the modulus for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
208 def modulus(v)
209   @modulus = v
210 end
partition_type()

Determine the appropriate partition type for this partition by which methods were called on it.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
240 def partition_type
241   raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1
242 
243   if @from || @to
244     raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to
245     :range
246   elsif @in
247     :list
248   elsif @modulus || @remainder
249     raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder
250     :hash
251   elsif @default
252     :default
253   else
254     raise Error, "unable to determine partition type, no partitioning methods called"
255   end
256 end
range()

The from and to values of this partition for a range partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
224 def range
225   [@from, @to]
226 end
remainder(v)

Assumes hash partitioning, sets the remainder for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
213 def remainder(v)
214   @remainder = v
215 end
to(*v)

Assumes range partitioning, sets the exclusive maximum value of the range for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
198 def to(*v)
199   @to = v
200 end
values_in(*v)

Assumes list partitioning, sets the values to be included in this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
203 def values_in(*v)
204   @in = v
205 end