class Sequel::Postgres::CreatePartitionOfTableGenerator

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

Constants

MAXVALUE
MINVALUE

Public Class Methods

new(&block) click to toggle source
# File lib/sequel/adapters/shared/postgres.rb, line 155
def initialize(&block)
  instance_exec(&block)
end

Public Instance Methods

default() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 200
def default
  @default = true
end
from(*v) click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 173
def from(*v)
  @from = v
end
hash_values() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 215
def hash_values
  [@modulus, @remainder]
end
list() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 210
def list
  @in
end
maxvalue() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 167
def maxvalue
  MAXVALUE
end
minvalue() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 161
def minvalue
  MINVALUE
end
modulus(v) click to toggle source

Assumes hash partitioning, sets the modulus for this parition.

# File lib/sequel/adapters/shared/postgres.rb, line 189
def modulus(v)
  @modulus = v
end
partition_type() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 221
def partition_type
  raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1

  if @from || @to
    raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to
    :range
  elsif @in
    :list
  elsif @modulus || @remainder
    raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder
    :hash
  elsif @default
    :default
  else
    raise Error, "unable to determine partition type, no partitioning methods called"
  end
end
range() click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 205
def range
  [@from, @to]
end
remainder(v) click to toggle source

Assumes hash partitioning, sets the remainder for this parition.

# File lib/sequel/adapters/shared/postgres.rb, line 194
def remainder(v)
  @remainder = v
end
to(*v) click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 179
def to(*v)
  @to = v
end
values_in(*v) click to toggle source

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

# File lib/sequel/adapters/shared/postgres.rb, line 184
def values_in(*v)
  @in = v
end