Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sql/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ type TriggerDefinition struct {
Name string // The name of this trigger. Trigger names in a database are unique.
CreateStatement string // The text of the statement to create this trigger.
CreatedAt time.Time // The time that the trigger was created.
Callback func() // Optional Go callback invoked after each row the trigger fires on. Not persisted.
}

// TriggerDatabase is a Database that supports the creation and execution of triggers. The engine handles all parsing
Expand Down
6 changes: 6 additions & 0 deletions sql/plan/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,15 @@ func (t *triggerIter) Next(ctx *sql.Context) (row sql.Row, returnErr error) {
// For some logic statements, we want to return the result of the logic operation as our row, e.g. a Set that alters
// the fields of the new row
if ok, returnRow := shouldUseLogicResult(logic, logicRow); ok {
if t.TriggerDefinition.Callback != nil {
t.TriggerDefinition.Callback()
}
return returnRow, nil
}

if t.TriggerDefinition.Callback != nil {
t.TriggerDefinition.Callback()
}
return childRow, nil
}

Expand Down
Loading