Re: Error message with plpgsql CONTINUE
От | Tom Lane |
---|---|
Тема | Re: Error message with plpgsql CONTINUE |
Дата | |
Msg-id | 24629.1440273200@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Error message with plpgsql CONTINUE (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Error message with plpgsql CONTINUE
|
Список | pgsql-hackers |
I had a few second thoughts about the wording of the error messages in this area. First, consider create or replace function foo() returns void language plpgsql as $$ begin <<lab1>> loop exit lab1; -- ok end loop; loop exit lab1; -- not so ok end loop; end$$; ERROR: label "lab1" does not exist LINE 8: exit lab1; -- not so ok ^ This message seems confusing: label "lab1" does exist, it's just not attached to the right loop. In a larger function that might not be too obvious, and I can easily imagine somebody wasting some time before figuring out the cause of his problem. Given the way the namespace data structure works, I am not sure that we can realistically detect at line 8 that there was an instance of lab1 earlier, but perhaps we could word the error message to cover either possibility. Maybe something like "there is no label "foo" surrounding this statement"? Second, consider create or replace function foo() returns void language plpgsql as $$ begin <<lab1>> begin exit lab1; -- ok exit; -- not so ok end; end$$; ERROR: EXIT cannot be used outside a loop LINE 6: exit; -- not so ok ^ This is not too accurate, as shown by the fact that the first EXIT is accepted. Perhaps "EXIT without a label cannot be used outside a loop"? I realize that this is pretty nitpicky, but if we're going to all the trouble of improving the error messages about these things, seems like we ought to be careful about what the messages actually say. I'm not married to these particular wordings though. Suggestions? regards, tom lane
В списке pgsql-hackers по дате отправления: