pgsql: Use setenv() in preference to putenv().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Use setenv() in preference to putenv().
Дата
Msg-id E1kufi6-0003CB-4N@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Use setenv() in preference to putenv().
Список pgsql-committers
Use setenv() in preference to putenv().

Since at least 2001 we've used putenv() and avoided setenv(), on the
grounds that the latter was unportable and not in POSIX.  However,
POSIX added it that same year, and by now the situation has reversed:
setenv() is probably more portable than putenv(), since POSIX now
treats the latter as not being a core function.  And setenv() has
cleaner semantics too.  So, let's reverse that old policy.

This commit adds a simple src/port/ implementation of setenv() for
any stragglers (we have one in the buildfarm, but I'd not be surprised
if that code is never used in the field).  More importantly, extend
win32env.c to also support setenv().  Then, replace usages of putenv()
with setenv(), and get rid of some ad-hoc implementations of setenv()
wannabees.

Also, adjust our src/port/ implementation of unsetenv() to follow the
POSIX spec that it returns an error indicator, rather than returning
void as per the ancient BSD convention.  I don't feel a need to make
all the call sites check for errors, but the portability stub ought
to match real-world practice.

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

Branch
------
master

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

Modified Files
--------------
configure                                  | 19 ++++++++++-
configure.ac                               |  4 ++-
contrib/dblink/input/paths.source          |  6 ++--
contrib/dblink/output/paths.source         |  6 ++--
src/backend/utils/adt/pg_locale.c          | 31 ++---------------
src/bin/initdb/initdb.c                    | 10 +++---
src/bin/pg_ctl/pg_ctl.c                    | 12 +++----
src/bin/pg_upgrade/controldata.c           | 54 +++++++++++++++++++-----------
src/bin/pg_upgrade/option.c                |  6 ++--
src/bin/pg_upgrade/pg_upgrade.h            |  1 -
src/bin/pg_upgrade/util.c                  | 36 --------------------
src/bin/psql/command.c                     | 11 +-----
src/common/exec.c                          | 22 ++----------
src/common/restricted_token.c              |  2 +-
src/include/pg_config.h.in                 |  3 ++
src/include/port.h                         |  6 +++-
src/include/port/win32_port.h              | 10 +++---
src/interfaces/ecpg/test/pg_regress_ecpg.c |  6 ++--
src/port/setenv.c                          | 48 ++++++++++++++++++++++++++
src/port/unsetenv.c                        | 18 +++++++---
src/port/win32env.c                        | 50 +++++++++++++++++++++++----
src/test/isolation/isolation_main.c        |  6 ++--
src/test/regress/pg_regress.c              | 45 ++++++++++---------------
src/test/regress/pg_regress_main.c         |  6 ++--
src/test/regress/regress.c                 | 14 +++-----
src/tools/msvc/Solution.pm                 |  1 +
26 files changed, 234 insertions(+), 199 deletions(-)


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

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: pgsql: Add support of multirange matching to the existing range GiST in
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Refactor multirange_in()