Tweak wording of syntax error messages about bad CONTINUE/EXIT statements.
Try to avoid any possible confusion about what these messages mean.
This commit is contained in:
parent
aad663a0b4
commit
18391a8f06
@ -1676,11 +1676,11 @@ stmt_exit : exit_type opt_label opt_exitcond
|
|||||||
if (label == NULL)
|
if (label == NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("label \"%s\" does not exist",
|
errmsg("there is no label \"%s\" surrounding this statement",
|
||||||
$2),
|
$2),
|
||||||
parser_errposition(@2)));
|
parser_errposition(@2)));
|
||||||
/* CONTINUE only allows loop labels */
|
/* CONTINUE only allows loop labels */
|
||||||
if (label->itemno != PLPGSQL_LABEL_LOOP && !$1)
|
if (label->itemno != PLPGSQL_LABEL_LOOP && !new->is_exit)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("block label \"%s\" cannot be used in CONTINUE",
|
errmsg("block label \"%s\" cannot be used in CONTINUE",
|
||||||
@ -1697,9 +1697,9 @@ stmt_exit : exit_type opt_label opt_exitcond
|
|||||||
if (plpgsql_ns_find_nearest_loop(plpgsql_ns_top()) == NULL)
|
if (plpgsql_ns_find_nearest_loop(plpgsql_ns_top()) == NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
/* translator: %s is EXIT or CONTINUE */
|
new->is_exit ?
|
||||||
errmsg("%s cannot be used outside a loop",
|
errmsg("EXIT cannot be used outside a loop, unless it has a label") :
|
||||||
plpgsql_stmt_typename((PLpgSQL_stmt *) new)),
|
errmsg("CONTINUE cannot be used outside a loop"),
|
||||||
parser_errposition(@1)));
|
parser_errposition(@1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2843,7 +2843,7 @@ $$ language plpgsql;
|
|||||||
ERROR: CONTINUE cannot be used outside a loop
|
ERROR: CONTINUE cannot be used outside a loop
|
||||||
LINE 4: continue;
|
LINE 4: continue;
|
||||||
^
|
^
|
||||||
-- should fail: EXIT is only legal inside a loop
|
-- should fail: unlabeled EXIT is only legal inside a loop
|
||||||
create function exit_error1() returns void as $$
|
create function exit_error1() returns void as $$
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
@ -2851,7 +2851,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
ERROR: EXIT cannot be used outside a loop
|
ERROR: EXIT cannot be used outside a loop, unless it has a label
|
||||||
LINE 4: exit;
|
LINE 4: exit;
|
||||||
^
|
^
|
||||||
-- should fail: no such label
|
-- should fail: no such label
|
||||||
@ -2864,7 +2864,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
ERROR: label "no_such_label" does not exist
|
ERROR: there is no label "no_such_label" surrounding this statement
|
||||||
LINE 5: continue no_such_label;
|
LINE 5: continue no_such_label;
|
||||||
^
|
^
|
||||||
-- should fail: no such label
|
-- should fail: no such label
|
||||||
@ -2877,7 +2877,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
ERROR: label "no_such_label" does not exist
|
ERROR: there is no label "no_such_label" surrounding this statement
|
||||||
LINE 5: exit no_such_label;
|
LINE 5: exit no_such_label;
|
||||||
^
|
^
|
||||||
-- should fail: CONTINUE can't reference the label of a named block
|
-- should fail: CONTINUE can't reference the label of a named block
|
||||||
|
@ -2373,7 +2373,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
|
||||||
-- should fail: EXIT is only legal inside a loop
|
-- should fail: unlabeled EXIT is only legal inside a loop
|
||||||
create function exit_error1() returns void as $$
|
create function exit_error1() returns void as $$
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user