File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -1676,11 +1676,11 @@ stmt_exit : exit_type opt_label opt_exitcond
16761676 if (label == NULL )
16771677 ereport (ERROR,
16781678 (errcode (ERRCODE_SYNTAX_ERROR),
1679- errmsg (" label \" %s\" does not exist " ,
1679+ errmsg (" there is no label \" %s\" surrounding this statement " ,
16801680 $2 ),
16811681 parser_errposition (@2 )));
16821682 /* CONTINUE only allows loop labels */
1683- if (label->itemno != PLPGSQL_LABEL_LOOP && !$ 1 )
1683+ if (label->itemno != PLPGSQL_LABEL_LOOP && !new -> is_exit )
16841684 ereport (ERROR,
16851685 (errcode (ERRCODE_SYNTAX_ERROR),
16861686 errmsg (" block label \" %s\" cannot be used in CONTINUE" ,
@@ -1697,9 +1697,9 @@ stmt_exit : exit_type opt_label opt_exitcond
16971697 if (plpgsql_ns_find_nearest_loop (plpgsql_ns_top ()) == NULL )
16981698 ereport (ERROR,
16991699 (errcode (ERRCODE_SYNTAX_ERROR),
1700- /* translator: %s is EXIT or CONTINUE */
1701- errmsg (" %s cannot be used outside a loop" ,
1702- plpgsql_stmt_typename ((PLpgSQL_stmt *) new ) ),
1700+ new -> is_exit ?
1701+ errmsg (" EXIT cannot be used outside a loop, unless it has a label " ) :
1702+ errmsg ( " CONTINUE cannot be used outside a loop " ),
17031703 parser_errposition (@1 )));
17041704 }
17051705
Original file line number Diff line number Diff line change @@ -2843,15 +2843,15 @@ $$ language plpgsql;
28432843ERROR: CONTINUE cannot be used outside a loop
28442844LINE 4: continue;
28452845 ^
2846- -- should fail: EXIT is only legal inside a loop
2846+ -- should fail: unlabeled EXIT is only legal inside a loop
28472847create function exit_error1() returns void as $$
28482848begin
28492849 begin
28502850 exit;
28512851 end;
28522852end;
28532853$$ language plpgsql;
2854- ERROR: EXIT cannot be used outside a loop
2854+ ERROR: EXIT cannot be used outside a loop, unless it has a label
28552855LINE 4: exit;
28562856 ^
28572857-- should fail: no such label
@@ -2864,7 +2864,7 @@ begin
28642864 end;
28652865end;
28662866$$ language plpgsql;
2867- ERROR: label "no_such_label" does not exist
2867+ ERROR: there is no label "no_such_label" surrounding this statement
28682868LINE 5: continue no_such_label;
28692869 ^
28702870-- should fail: no such label
@@ -2877,7 +2877,7 @@ begin
28772877 end;
28782878end;
28792879$$ language plpgsql;
2880- ERROR: label "no_such_label" does not exist
2880+ ERROR: there is no label "no_such_label" surrounding this statement
28812881LINE 5: exit no_such_label;
28822882 ^
28832883-- should fail: CONTINUE can't reference the label of a named block
Original file line number Diff line number Diff line change @@ -2373,7 +2373,7 @@ begin
23732373end;
23742374$$ language plpgsql;
23752375
2376- -- should fail: EXIT is only legal inside a loop
2376+ -- should fail: unlabeled EXIT is only legal inside a loop
23772377create function exit_error1 () returns void as $$
23782378begin
23792379 begin
You can’t perform that action at this time.
0 commit comments