TriggerCall runs the contained trigger operations on the given runner.
(ctx *sql.Context, iFunc InterpretedFunction, runner sql.StatementRunner, sch sql.Schema, oldRow sql.Row, newRow sql.Row, trigVars map[string]any)
| 67 | |
| 68 | // TriggerCall runs the contained trigger operations on the given runner. |
| 69 | func TriggerCall(ctx *sql.Context, iFunc InterpretedFunction, runner sql.StatementRunner, sch sql.Schema, oldRow sql.Row, newRow sql.Row, trigVars map[string]any) (any, error) { |
| 70 | // Set up the initial state of the function |
| 71 | stack := NewInterpreterStack(runner) |
| 72 | // Add the special variables |
| 73 | stack.NewRecord("OLD", sch, oldRow) |
| 74 | stack.NewRecord("NEW", sch, newRow) |
| 75 | for varName, val := range trigVars { |
| 76 | varType, ok := triggerSpecialVariables[varName] |
| 77 | if !ok { |
| 78 | return nil, fmt.Errorf("unknown variable %s for trigger", varName) |
| 79 | } |
| 80 | stack.NewVariableWithValue(varName, varType, val) |
| 81 | } |
| 82 | return call(ctx, iFunc, stack) |
| 83 | } |
| 84 | |
| 85 | // call runs the contained operations on the given runner. |
| 86 | func call(ctx *sql.Context, iFunc InterpretedFunction, stack InterpreterStack) (any, error) { |
no test coverage detected