Re: plpgsql unreachable code (was BUG #1329: Bug in IF-ELSEIF-ELSE construct)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: plpgsql unreachable code (was BUG #1329: Bug in IF-ELSEIF-ELSE construct)
Дата
Msg-id 26640.1101577433@sss.pgh.pa.us
обсуждение исходный текст
Ответ на plpgsql unreachable code (was BUG #1329: Bug in IF-ELSEIF-ELSE construct)  (Neil Conway <neilc@samurai.com>)
Список pgsql-patches
Neil Conway <neilc@samurai.com> writes:
>> (BTW, another thing this example exposes is that we don't issue warnings
>> about trivially-dead-code, such as statements in a basic block that
>> follow a RETURN. This would probably be also worth doing.)

> Attached is a patch that implements this. Specifically, if there are any
> statements in the same block that follow a RETURN, EXIT (without
> condition) or RAISE EXCEPTION statement, we issue a warning at CREATE
> FUNCTION time:

I think it would be sufficient to warn about the statement immediately
following the RETURN, EXIT, etc.  The way you've got it could easily
bury the user in a mass of warning messages that don't really convey
any extra information.

You could possibly give two alternative messages:
    WARNING:  assignment is unreachable, due to exit near line 6
    WARNING:  assignment and following statement(s) are unreachable, due to exit near line 6
but I'm not sure that's worth the trouble.

Also, you must use ereport not elog for any user-facing error messages,
because elog messages aren't candidates for translation.

            regards, tom lane

В списке pgsql-patches по дате отправления:

Предыдущее
От: Neil Conway
Дата:
Сообщение: plpgsql unreachable code (was BUG #1329: Bug in IF-ELSEIF-ELSE construct)
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: SQL conformance related patch