MCPcopy Create free account
hub / github.com/dolthub/doltgresql / AppendOperations

Method AppendOperations

server/plpgsql/statements.go:269–297  ·  view source on GitHub ↗

AppendOperations implements the interface Statement.

(ops *[]InterpreterOperation, stack *InterpreterStack)

Source from the content-addressed store, hash-verified

267
268// AppendOperations implements the interface Statement.
269func (stmt Goto) AppendOperations(ops *[]InterpreterOperation, stack *InterpreterStack) error {
270 if len(stmt.Label) > 0 {
271 *ops = append(*ops, InterpreterOperation{
272 OpCode: OpCode_Goto,
273 PrimaryData: stmt.Label,
274 Index: int(stmt.Offset),
275 })
276 } else if stmt.NearestScopeOp {
277 label := stack.GetCurrentLabel()
278 if len(label) == 0 {
279 if stmt.Offset > 0 {
280 return errors.New("EXIT cannot be used outside a loop, unless it has a label")
281 } else {
282 return errors.New("CONTINUE cannot be used outside a loop")
283 }
284 }
285 *ops = append(*ops, InterpreterOperation{
286 OpCode: OpCode_Goto,
287 PrimaryData: label,
288 Index: int(stmt.Offset),
289 })
290 } else {
291 *ops = append(*ops, InterpreterOperation{
292 OpCode: OpCode_Goto,
293 Index: len(*ops) + int(stmt.Offset),
294 })
295 }
296 return nil
297}
298
299// If represents an IF condition, alongside its Goto offset if the condition is true.
300type If struct {

Callers

nothing calls this directly

Calls 1

GetCurrentLabelMethod · 0.80

Tested by

no test coverage detected