## Code Analysis ### Function creation dispatches labeled EXIT statements `server/plpgsql/json_convert.go:129-174` ```go func jsonConvertStatement(stmt statement, datums datumNames) (Statement, error) { switch { case stmt.Exit != nil: return stmt.Exit.Convert(), nil // ... other recognized statement arms ... default: return Block{}, errors.Errorf("unhandled statement type: %T", stmt) } } ``` The function-creation conversion path accepts a decoded statement only when one of the recognized arms is populated. Otherwise it returns the observed `unhandled statement type` error before the function can be invoked. ### Labeled EXIT is represented as a labeled jump `server/plpgsql/json.go:174-180, 515-547` ```go type plpgSQL_stmt_exit struct { Label string `json:"label"` IsExit bool `json:"is_exit"` Condition *expr `json:"cond"` LineNumber int32 `json:"lineno"` } if len(stmt.Label) > 0 { gotoStmt = Goto{Offset: offset, Label: stmt.Label} } ``` The source defines a decoded labeled EXIT and a conversion to a labeled `Goto`, establishing the intended control-flow representation. The recorded failure occurs earlier, in statement conversion, so the loop body and `FOUND` update are not reached. ### Existing regression requirement `testing/go/plpgsql_found_test.go:340-361` ```go Query: `CREATE FUNCTION f_labelled_exit() RETURNS int LANGUAGE plpgsql AS $$ ... <> FOR r IN SELECT id FROM k ORDER BY id LOOP FOR s IN SELECT id FROM k ORDER BY id LOOP n := n + 1; EXIT outer; ... IF NOT FOUND THEN RETURN -1; END IF; RETURN n; END; $$;`, Expected: []sql.Row{}, ... Query: `SELECT f_labelled_exit();`, Expected: []sql.Row{{1}}, ``` The repository regression test requires the function to be created and then return `1` after the labeled outer exit, with `FOUND` remaining true. ### Observed execution ```text # BF-ORDER-2 labeled outer exit # Command: docker exec -i aefd1e22c181 env PGPASSWORD=[REDACTED] psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -U postgres -d postgres # Fixture: tags rows (1, {a,b}) and (2, {c}) # Function definition was rejected before invocation. ERROR: unhandled statement type: plpgsql.statement # Expected: outer_count=1, inner_count=1, found_after=true, trace={"1:1"} # Result: counters and FOUND were not observable. ``` The captured `CREATE FUNCTION` attempt failed with the same fallback error described by the conversion source path. Because creation failed, no invocation or runtime counter/`FOUND` readback was produced. ### Result The runtime payload and source excerpts support the reported failure: the labeled-loop function is rejected during creation with `unhandled statement type: plpgsql.statement`, before the expected outer-loop exit and `FOUND` result can execute. ### Test context No stubs, mocks, or bypasses were recorded for this test.