triggers

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TriggerIDToTableName

func TriggerIDToTableName(trigID id.Trigger) doltdb.TableName

TriggerIDToTableName returns the ID in a format that's better for user consumption.

Types

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

Collection contains a collection of triggers.

func LoadTriggers

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

LoadTriggers loads the triggers collection from the given root.

func NewCollection

func NewCollection(ctx context.Context, underlyingMap prolly.AddressMap, ns tree.NodeStore) (*Collection, error)

NewCollection returns a new Collection.

func (*Collection) AddTrigger

func (pgt *Collection) AddTrigger(ctx context.Context, t Trigger) error

AddTrigger adds a new trigger.

func (*Collection) Clone

func (pgt *Collection) Clone(ctx context.Context) *Collection

Clone returns a new *Collection with the same contents as the original.

func (*Collection) DeserializeRootObject added in v0.51.1

func (pgt *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

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

DiffersFrom returns true when the hash that is associated with the underlying map for this collection is different from the hash in the given root.

func (*Collection) DropRootObject

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

DropRootObject implements the interface objinterface.Collection.

func (*Collection) DropTrigger

func (pgt *Collection) DropTrigger(ctx context.Context, trigIDs ...id.Trigger) error

DropTrigger drops an existing trigger.

func (*Collection) GetFieldType added in v0.51.1

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

GetFieldType implements the interface objinterface.Collection.

func (*Collection) GetID

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

GetID implements the interface objinterface.Collection.

func (*Collection) GetRootObject

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

GetRootObject implements the interface objinterface.Collection.

func (*Collection) GetTrigger

func (pgt *Collection) GetTrigger(ctx context.Context, trigID id.Trigger) (Trigger, error)

GetTrigger returns the trigger with the given ID. Returns a trigger with an invalid ID if it cannot be found (Trigger.ID.IsValid() == false).

func (*Collection) GetTriggerIDsForTable

func (pgt *Collection) GetTriggerIDsForTable(ctx context.Context, tableID id.Table) []id.Trigger

GetTriggerIDsForTable returns the trigger IDs for the given table.

func (*Collection) GetTriggersForTable

func (pgt *Collection) GetTriggersForTable(ctx context.Context, tableID id.Table) []Trigger

GetTriggersForTable returns the triggers for the given table.

func (*Collection) GetTriggersForTableByTiming

func (pgt *Collection) GetTriggersForTableByTiming(ctx context.Context, tableID id.Table, timing TriggerTiming) []Trigger

GetTriggersForTableByTiming returns the triggers for the given table, all matching the given timing. These triggers are also sorted by their name ascending.

func (*Collection) HandleMerge

HandleMerge implements the interface objinterface.Collection.

func (*Collection) HasRootObject

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

HasRootObject implements the interface objinterface.Collection.

func (*Collection) HasTrigger

func (pgt *Collection) HasTrigger(ctx context.Context, trigID id.Trigger) bool

HasTrigger returns whether the trigger is present.

func (*Collection) IDToTableName

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

IDToTableName implements the interface objinterface.Collection.

func (*Collection) IterAll

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

IterAll implements the interface objinterface.Collection.

func (*Collection) IterIDs

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

IterIDs implements the interface objinterface.Collection.

func (*Collection) IterateTriggers

func (pgt *Collection) IterateTriggers(ctx context.Context, callback func(t Trigger) (stop bool, err error)) error

IterateTriggers iterates over all triggers in the collection.

func (*Collection) LoadCollection

LoadCollection implements the interface objinterface.Collection.

func (*Collection) LoadCollectionHash

func (*Collection) LoadCollectionHash(ctx context.Context, root objinterface.RootValue) (hash.Hash, error)

LoadCollectionHash implements the interface objinterface.Collection.

func (*Collection) Map

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

Map writes any cached sequences to the underlying map, and then returns the underlying map.

func (*Collection) PutRootObject

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

PutRootObject implements the interface objinterface.Collection.

func (*Collection) RenameRootObject

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

RenameRootObject implements the interface objinterface.Collection.

func (*Collection) ResolveName

func (pgt *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

Serializer implements the interface objinterface.Collection.

func (*Collection) TableNameToID

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

TableNameToID implements the interface objinterface.Collection.

func (*Collection) UpdateField added in v0.51.1

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

UpdateField implements the interface objinterface.Collection.

func (*Collection) UpdateRoot

UpdateRoot implements the interface objinterface.Collection.

type Trigger

type Trigger struct {
	ID                  id.Trigger
	Function            id.Function
	Timing              TriggerTiming
	Events              []TriggerEvent
	ForEachRow          bool // When false, represents FOR EACH STATEMENT
	When                []plpgsql.InterpreterOperation
	Deferrable          TriggerDeferrable
	ReferencedTableName id.Table // FROM referenced_table_name
	Constraint          bool
	OldTransitionName   string // REFERENCING OLD TABLE AS transition_relation_name
	NewTransitionName   string // REFERENCING NEW TABLE AS transition_relation_name
	Arguments           []string
	Definition          string
}

Trigger represents a trigger.

func DeserializeTrigger

func DeserializeTrigger(ctx context.Context, data []byte) (Trigger, error)

DeserializeTrigger returns the Trigger that was serialized in the byte slice. Returns an empty Trigger (invalid ID) if data is nil or empty.

func (Trigger) GetID

func (trigger Trigger) GetID() id.Id

GetID implements the interface objinterface.RootObject.

func (Trigger) GetRootObjectID added in v0.51.1

func (trigger Trigger) GetRootObjectID() objinterface.RootObjectID

GetRootObjectID implements the interface objinterface.RootObject.

func (Trigger) HashOf

func (trigger Trigger) HashOf(ctx context.Context) (hash.Hash, error)

HashOf implements the interface objinterface.RootObject.

func (Trigger) Name

func (trigger Trigger) Name() doltdb.TableName

Name implements the interface objinterface.RootObject.

func (Trigger) Serialize

func (trigger Trigger) Serialize(ctx context.Context) ([]byte, error)

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

type TriggerDeferrable

type TriggerDeferrable uint8

TriggerDeferrable specifies whether the trigger is deferrable.

const (
	TriggerDeferrable_NotDeferrable       TriggerDeferrable = 0 // NOT DEFERRABLE
	TriggerDeferrable_DeferrableImmediate TriggerDeferrable = 1 // DEFERRABLE INITIALLY IMMEDIATE
	TriggerDeferrable_DeferrableDeferred  TriggerDeferrable = 2 // DEFERRABLE INITIALLY DEFERRED
)

type TriggerEvent

type TriggerEvent struct {
	Type        TriggerEventType
	ColumnNames []string
}

TriggerEvent specifies the event type, along with column information for update events.

type TriggerEventType

type TriggerEventType uint8

TriggerEventType specifies which type of event that the trigger applies to.

const (
	TriggerEventType_Insert   TriggerEventType = 0
	TriggerEventType_Update   TriggerEventType = 1
	TriggerEventType_Delete   TriggerEventType = 2
	TriggerEventType_Truncate TriggerEventType = 3
)

type TriggerTiming

type TriggerTiming uint8

TriggerTiming specifies the timing of the trigger's execution.

const (
	TriggerTiming_Before    TriggerTiming = 0
	TriggerTiming_After     TriggerTiming = 1
	TriggerTiming_InsteadOf TriggerTiming = 2
)

Jump to

Keyboard shortcuts

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