pgsql: Clean up inconsistent use of fflush().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Clean up inconsistent use of fflush().
Дата
Msg-id E1oSizH-000UUD-2n@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Clean up inconsistent use of fflush().

More than twenty years ago (79fcde48b), we hacked the postmaster
to avoid a core-dump on systems that didn't support fflush(NULL).
We've mostly, though not completely, hewed to that rule ever since.
But such systems are surely gone in the wild, so in the spirit of
cleaning out no-longer-needed portability hacks let's get rid of
multiple per-file fflush() calls in favor of using fflush(NULL).

Also, we were fairly inconsistent about whether to fflush() before
popen() and system() calls.  While we've received no bug reports
about that, it seems likely that at least some of these call sites
are at risk of odd behavior, such as error messages appearing in
an unexpected order.  Rather than expend a lot of brain cells
figuring out which places are at hazard, let's just establish a
uniform coding rule that we should fflush(NULL) before these calls.
A no-op fflush() is surely of trivial cost compared to launching
a sub-process via a shell; while if it's not a no-op then we likely
need it.

Discussion: https://postgr.es/m/2923412.1661722825@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7fed801135bae14d63b11ee4a10f6083767046d8

Modified Files
--------------
src/backend/access/transam/xlogarchive.c  |  2 ++
src/backend/postmaster/fork_process.c     |  7 +------
src/backend/postmaster/shell_archive.c    |  1 +
src/backend/storage/file/fd.c             |  3 +--
src/backend/utils/error/elog.c            |  6 ++----
src/bin/initdb/initdb.c                   |  5 +++--
src/bin/pg_ctl/pg_ctl.c                   |  5 +++--
src/bin/pg_dump/pg_dumpall.c              |  3 +--
src/bin/pg_rewind/pg_rewind.c             |  1 +
src/bin/pg_upgrade/controldata.c          |  6 ++----
src/bin/pg_upgrade/exec.c                 |  7 +++++++
src/bin/pg_upgrade/option.c               |  1 +
src/bin/pg_verifybackup/pg_verifybackup.c |  1 +
src/bin/pgbench/pgbench.c                 |  2 ++
src/bin/psql/command.c                    |  4 ++++
src/bin/psql/common.c                     |  1 +
src/bin/psql/copy.c                       |  8 +++-----
src/bin/psql/prompt.c                     |  4 +++-
src/bin/psql/psqlscanslash.l              |  1 +
src/common/exec.c                         |  4 +---
src/fe_utils/archive.c                    |  1 +
src/fe_utils/print.c                      |  1 +
src/interfaces/libpq/fe-print.c           |  1 +
src/test/regress/pg_regress.c             | 18 ++++++++----------
24 files changed, 52 insertions(+), 41 deletions(-)


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: Remove stray "the".
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Cleanup more code and comments related to Windows NT4 (XP days)