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
169 def initialize(&block)
170   instance_exec(&block)
171 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
214 def default
215   @default = true
216 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
187 def from(*v)
188   @from = v
189 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
229 def hash_values
230   [@modulus, @remainder]
231 end
list()

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

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
224 def list
225   @in
226 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
181 def maxvalue
182   MAXVALUE
183 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
175 def minvalue
176   MINVALUE
177 end
modulus(v)

Assumes hash partitioning, sets the modulus for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
203 def modulus(v)
204   @modulus = v
205 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
235 def partition_type
236   raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1
237 
238   if @from || @to
239     raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to
240     :range
241   elsif @in
242     :list
243   elsif @modulus || @remainder
244     raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder
245     :hash
246   elsif @default
247     :default
248   else
249     raise Error, "unable to determine partition type, no partitioning methods called"
250   end
251 end
range()

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

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

Assumes hash partitioning, sets the remainder for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
208 def remainder(v)
209   @remainder = v
210 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
193 def to(*v)
194   @to = v
195 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
198 def values_in(*v)
199   @in = v
200 end