pgsql: Improve our response to invalid format strings,and detect more

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve our response to invalid format strings,and detect more
Дата
Msg-id E1gUzxL-0001jZ-O1@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve our response to invalid format strings, and detect more cases.

Places that are testing for *printf failure ought to include the format
string in their error reports, since bad-format-string is one of the
more likely causes of such failure.  This both makes it easier to find
and repair the mistake, and provides at least some useful info to the
user who stumbles across such a problem.

Also, tighten snprintf.c to report EINVAL for an invalid flag or
final character in a format %-spec (including the case where the
%-spec is missing a final character altogether).  This seems like
better project policy, and it also allows removing an instruction
or two from the hot code path.

Back-patch the error reporting change in pvsnprintf, since it should be
harmless and may be helpful; but not the snprintf.c change.

Per discussion of bug #15511 from Ertuğrul Kahveci, which reported an
invalid translated format string.  These changes don't fix that error,
but they should improve matters next time we make such a mistake.

Discussion: https://postgr.es/m/15511-1d8b6a0bc874112f@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d2b0b60e71931997455afd5da72ca29148f1ca51

Modified Files
--------------
src/backend/utils/misc/guc.c |  4 ++--
src/common/psprintf.c        |  4 ++--
src/port/snprintf.c          | 13 +++++++++----
3 files changed, 13 insertions(+), 8 deletions(-)


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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: pgsql: Improve planner stats documentation
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Fix some errhint and errdetail strings missing a period