sequences

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FIELD_NAME_DATA_TYPE       = "data_type"
	FIELD_NAME_PERSISTENCE     = "persistence"
	FIELD_NAME_START           = "start"
	FIELD_NAME_CURRENT         = "current"
	FIELD_NAME_INCREMENT       = "increment"
	FIELD_NAME_MINIMUM         = "minimum"
	FIELD_NAME_MAXIMUM         = "maximum"
	FIELD_NAME_CACHE           = "cache"
	FIELD_NAME_CYCLE           = "cycle"
	FIELD_NAME_IS_AT_END       = "is_at_end"
	FIELD_NAME_HAS_BEEN_CALLED = "has_been_called"
	FIELD_NAME_OWNER_TABLE     = "owner_table"
	FIELD_NAME_OWNER_COLUMN    = "owner_column"
)

Variables

View Source
var SequenceTrackerKey dsess.TrackerKey[*SequenceTracker] = struct{}{}

SequenceTrackerKey is the key to identify the SequenceTracker in the globalstate.GlobalState

Functions

This section is empty.

Types

type Collection

type Collection struct {
	objinterface.RootObjectMap
	// contains filtered or unexported fields
}

Collection contains a collection of sequences.

func LoadSequences added in v0.50.0

func LoadSequences(ctx context.Context, root objinterface.RootValue) (*Collection, error)

LoadSequences loads the sequences collection from the given root.

func (*Collection) CreateSequence

func (pgs *Collection) CreateSequence(ctx context.Context, seq *Sequence) error

CreateSequence creates a new sequence.

func (*Collection) DeserializeRootObject added in v0.51.1

func (pgs *Collection) DeserializeRootObject(ctx context.Context, data []byte) (objinterface.RootObject, error)

DeserializeRootObject implements the interface objinterface.Collection.

func (*Collection) DiffRootObjects added in v0.51.1

DiffRootObjects implements the interface objinterface.Collection.

func (*Collection) DiffersFrom added in v1.0.0

func (pgs *Collection) DiffersFrom(ctx context.Context, root objinterface.RootValue) (bool, error)

DiffersFrom implements the interface objinterface.Collection. The cache is flushed first, since sequences are written to the underlying map lazily.

func (*Collection) DropRootObject added in v0.50.0

func (pgs *Collection) DropRootObject(ctx context.Context, identifier id.Id) error

DropRootObject implements the interface objinterface.Collection.

func (*Collection) DropSequence

func (pgs *Collection) DropSequence(ctx context.Context, names ...id.Sequence) (err error)

DropSequence drops existing sequences.

func (*Collection) GetAllSequences added in v0.10.0

func (pgs *Collection) GetAllSequences(ctx context.Context) (sequences map[string][]*Sequence, schemaNames []string, totalCount int, err error)

GetAllSequences returns a map containing all sequences in the collection, grouped by the schema they're contained in. Each sequence array is also sorted by the sequence name.

func (*Collection) GetFieldType added in v0.51.1

func (pgs *Collection) GetFieldType(ctx context.Context, fieldName string) *pgtypes.DoltgresType

GetFieldType implements the interface objinterface.Collection.

func (*Collection) GetID added in v0.50.0

func (pgs *Collection) GetID() objinterface.RootObjectID

GetID implements the interface objinterface.Collection.

func (*Collection) GetRootObject added in v0.50.0

func (pgs *Collection) GetRootObject(ctx context.Context, identifier id.Id) (objinterface.RootObject, bool, error)

GetRootObject implements the interface objinterface.Collection.

func (*Collection) GetSequence added in v0.8.0

func (pgs *Collection) GetSequence(ctx context.Context, name id.Sequence) (*Sequence, error)

GetSequence returns the sequence with the given schema and name. Returns nil if the sequence cannot be found.

func (*Collection) GetSequencesWithTable added in v0.8.0

func (pgs *Collection) GetSequencesWithTable(ctx context.Context, name doltdb.TableName) ([]*Sequence, error)

GetSequencesWithTable returns all sequences with the given table as the owner.

func (*Collection) HandleMerge added in v0.50.0

HandleMerge implements the interface objinterface.Collection.

func (*Collection) HasRootObject added in v0.50.0

func (pgs *Collection) HasRootObject(ctx context.Context, identifier id.Id) (bool, error)

HasRootObject implements the interface objinterface.Collection.

func (*Collection) HasSequence

func (pgs *Collection) HasSequence(ctx context.Context, name id.Sequence) bool

HasSequence returns whether the sequence is present.

func (*Collection) IDToTableName added in v0.50.0

func (pgs *Collection) IDToTableName(identifier id.Id) doltdb.TableName

IDToTableName implements the interface objinterface.Collection.

func (*Collection) IterAll added in v0.50.0

func (pgs *Collection) IterAll(ctx context.Context, callback func(rootObj objinterface.RootObject) (stop bool, err error)) error

IterAll implements the interface objinterface.Collection.

func (*Collection) IterIDs added in v0.50.0

func (pgs *Collection) IterIDs(ctx context.Context, callback func(identifier id.Id) (stop bool, err error)) error

IterIDs implements the interface objinterface.Collection.

func (*Collection) IterateSequences added in v0.8.0

func (pgs *Collection) IterateSequences(ctx context.Context, f func(seq *Sequence) (stop bool, err error)) (err error)

IterateSequences iterates over all sequences in the collection.

func (*Collection) LoadCollection added in v0.50.0

LoadCollection implements the interface objinterface.Collection.

func (*Collection) Map added in v0.50.0

func (pgs *Collection) Map(ctx context.Context) (prolly.AddressMap, error)

Map writes any cached sequences to the collection's contents, and then returns those contents.

func (*Collection) NextVal

func (pgs *Collection) NextVal(ctx context.Context, name id.Sequence) (int64, error)

NextVal returns the next value in the sequence.

func (*Collection) PutRootObject added in v0.50.0

func (pgs *Collection) PutRootObject(ctx context.Context, rootObj objinterface.RootObject) error

PutRootObject implements the interface objinterface.Collection.

func (*Collection) RenameRootObject added in v0.50.0

func (pgs *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error

RenameRootObject implements the interface objinterface.Collection.

func (*Collection) ResolveName added in v0.50.0

func (pgs *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error)

ResolveName implements the interface objinterface.Collection.

func (*Collection) ResolveNameFromObjects added in v0.51.1

func (*Collection) ResolveNameFromObjects(ctx context.Context, name doltdb.TableName, rootObjects []objinterface.RootObject) (doltdb.TableName, id.Id, error)

ResolveNameFromObjects implements the interface objinterface.Collection.

func (*Collection) Serializer added in v0.50.0

Serializer implements the interface objinterface.Collection.

func (*Collection) SetVal

func (pgs *Collection) SetVal(ctx context.Context, name id.Sequence, newValue int64, hasBeenCalled bool, autoAdvance bool) error

SetVal sets the sequence to the

func (*Collection) TableNameToID added in v0.50.0

func (pgs *Collection) TableNameToID(name doltdb.TableName) id.Id

TableNameToID implements the interface objinterface.Collection.

func (*Collection) UpdateField added in v0.51.1

func (pgs *Collection) UpdateField(ctx context.Context, rootObject objinterface.RootObject, fieldName string, newValue any) (objinterface.RootObject, error)

UpdateField implements the interface objinterface.Collection.

func (*Collection) UpdateRoot added in v0.50.0

UpdateRoot implements the interface objinterface.Collection.

type Persistence

type Persistence uint8

Persistence controls the persistence of a Sequence.

const (
	Persistence_Permanent Persistence = 0
	Persistence_Temporary Persistence = 1
	Persistence_Unlogged  Persistence = 2
)

type Sequence

type Sequence struct {
	DataTypeID  id.Type
	Persistence Persistence
	SequenceState
	OwnerTable  id.Table
	OwnerColumn string
}

Sequence represents a single sequence within the pg_sequence table.

func DeserializeSequence added in v0.50.0

func DeserializeSequence(_ context.Context, data []byte) (*Sequence, error)

DeserializeSequence returns the Sequence that was serialized in the byte slice. Returns an empty Sequence if data is nil or empty.

func (*Sequence) GetID added in v0.50.0

func (sequence *Sequence) GetID() id.Id

GetID implements the interface objinterface.RootObject.

func (*Sequence) GetRootObjectID added in v0.51.1

func (sequence *Sequence) GetRootObjectID() objinterface.RootObjectID

GetRootObjectID implements the interface objinterface.RootObject.

func (*Sequence) GetSequenceSqlType added in v1.0.0

func (sequence *Sequence) GetSequenceSqlType(ctx context.Context) (sql.Type, bool, error)

func (*Sequence) GetSequenceState added in v1.0.0

func (sequence *Sequence) GetSequenceState(ctx context.Context) (SequenceState, error)

func (*Sequence) HasSequenceState added in v1.0.0

func (sequence *Sequence) HasSequenceState(ctx context.Context) (bool, error)

func (*Sequence) HashOf added in v0.50.0

func (sequence *Sequence) HashOf(ctx context.Context) (hash.Hash, error)

HashOf implements the interface rootobject.RootObject.

func (*Sequence) Name

func (sequence *Sequence) Name() doltdb.TableName

Name implements the interface rootobject.RootObject.

func (*Sequence) Serialize added in v0.50.0

func (sequence *Sequence) Serialize(ctx context.Context) ([]byte, error)

Serialize returns the Sequence as a byte slice. If the Sequence is nil, then this returns a nil slice.

func (*Sequence) SetSequenceState added in v1.0.0

func (sequence *Sequence) SetSequenceState(ctx context.Context, newSequenceState SequenceState) (*Sequence, error)

func (*Sequence) TrySetSequenceState added in v1.0.0

func (sequence *Sequence) TrySetSequenceState(ctx *sql.Context, val SequenceState) (*Sequence, bool, error)

type SequenceSource added in v1.0.0

type SequenceSource struct{}

SequenceSource reads relations from a RootValue by reading its RootObjects

func (SequenceSource) GetRelation added in v1.0.0

func (s SequenceSource) GetRelation(ctx context.Context, root doltdb.RootValue, tName doltdb.TableName) (relation *Sequence, resolvedName string, found bool, err error)

func (SequenceSource) IterRelations added in v1.0.0

type SequenceState added in v1.0.0

type SequenceState struct {
	Id            id.Sequence
	Start         int64
	Current       int64
	Increment     int64
	Minimum       int64
	Maximum       int64
	Cache         int64
	Cycle         bool
	IsAtEnd       bool
	HasBeenCalled bool
}

func (SequenceState) AtEnd added in v1.0.0

func (sequence SequenceState) AtEnd() bool

func (SequenceState) CurrentValue added in v1.0.0

func (sequence SequenceState) CurrentValue() int64

func (SequenceState) GreaterThan added in v1.0.0

func (sequence SequenceState) GreaterThan(other SequenceState) bool

func (SequenceState) Merge added in v1.0.0

func (sequence SequenceState) Merge(otherSequenceState SequenceState) (merged SequenceState)

func (SequenceState) Next added in v1.0.0

func (sequence SequenceState) Next() (sqlVal int64, hasNext bool, nextState SequenceState, err error)

func (SequenceState) WithSQLValue added in v1.0.0

func (sequence SequenceState) WithSQLValue(ctx *sql.Context, v interface{}) (SequenceState, error)

func (SequenceState) WithValue added in v1.0.0

func (sequence SequenceState) WithValue(v int64) SequenceState

type SequenceTracker added in v1.0.0

type SequenceTracker = dsess.SequenceTracker[*Sequence, SequenceState, int64]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL