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
156 def initialize(&block)
157   instance_exec(&block)
158 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
201 def default
202   @default = true
203 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
174 def from(*v)
175   @from = v
176 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
216 def hash_values
217   [@modulus, @remainder]
218 end
list()

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

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
211 def list
212   @in
213 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
168 def maxvalue
169   MAXVALUE
170 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
162 def minvalue
163   MINVALUE
164 end
modulus(v)

Assumes hash partitioning, sets the modulus for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
190 def modulus(v)
191   @modulus = v
192 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
222 def partition_type
223   raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1
224 
225   if @from || @to
226     raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to
227     :range
228   elsif @in
229     :list
230   elsif @modulus || @remainder
231     raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder
232     :hash
233   elsif @default
234     :default
235   else
236     raise Error, "unable to determine partition type, no partitioning methods called"
237   end
238 end
range()

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

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

Assumes hash partitioning, sets the remainder for this parition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
195 def remainder(v)
196   @remainder = v
197 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
180 def to(*v)
181   @to = v
182 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
185 def values_in(*v)
186   @in = v
187 end