FOUND is declared for every function and set by the statements PostgreSQL
defines as setting it: INTO clauses, bare DML, PERFORM, FOR..IN..SELECT,
RETURN QUERY, and both kinds of FOR loop on exit. A FOR loop reports
whether its body ran at all, which it records on its own scope rather
than in FOUND, since PostgreSQL leaves FOUND alone while the loop is
running. Every way of leaving a scope now routes through a single
exitScope, so a loop reports FOUND and closes its cursor whether it ends
normally, by EXIT, or by a labelled CONTINUE of an outer loop. A dynamic
EXECUTE and a utility statement such as CREATE TABLE deliberately leave
FOUND alone, so statements are classified at conversion time and the
opcode that dynamic execution shares with static execution is told apart
by an operation option.
FOUND is declared for every function and set by the statements PostgreSQL defines as setting it: INTO clauses, bare DML, PERFORM, FOR..IN..SELECT, RETURN QUERY, and both kinds of FOR loop on exit. A FOR loop reports whether its body ran at all, which it records on its own scope rather than in FOUND, since PostgreSQL leaves FOUND alone while the loop is running. Every way of leaving a scope now routes through a single exitScope, so a loop reports FOUND and closes its cursor whether it ends normally, by EXIT, or by a labelled CONTINUE of an outer loop. A dynamic EXECUTE and a utility statement such as CREATE TABLE deliberately leave FOUND alone, so statements are classified at conversion time and the opcode that dynamic execution shares with static execution is told apart by an operation option.