Per discussion, a little more verbosity seems called for.
if (label == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("there is no label \"%s\" surrounding this statement",
+ errmsg("there is no label \"%s\" "
+ "attached to any block or loop enclosing this statement",
$2),
parser_errposition(@2)));
/* CONTINUE only allows loop labels */
end;
end;
$$ language plpgsql;
-ERROR: there is no label "no_such_label" surrounding this statement
+ERROR: there is no label "no_such_label" attached to any block or loop enclosing this statement
LINE 5: continue no_such_label;
^
-- should fail: no such label
end;
end;
$$ language plpgsql;
-ERROR: there is no label "no_such_label" surrounding this statement
+ERROR: there is no label "no_such_label" attached to any block or loop enclosing this statement
LINE 5: exit no_such_label;
^
-- should fail: CONTINUE can't reference the label of a named block