pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Use setenv() in preference to putenv().
3+ messages / 2 participants
[nested] [flat]
* pgsql: Use setenv() in preference to putenv().
@ 2020-12-30 17:56 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2020-12-30 17:56 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Use setenv() in preference to putenv().
@ 2020-12-31 02:51 Alexander Korotkov <aekorotkov@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Korotkov @ 2020-12-31 02:51 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Hi!
On Wed, Dec 30, 2020 at 8:56 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Use setenv() in preference to putenv().
Recent buildfarm failure on crake seems to be related to this commit.
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=crake&dt=2020-12-31%2001%3A34%3A28
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 193; 1255 50888 FUNCTION putenv("text") buildfarm
pg_restore: error: could not execute query: ERROR: could not find
function "regress_putenv" in file
"/home/andrew/bf/root/saves.crake/HEAD/lib/postgresql/regress.so"
Command was: CREATE FUNCTION "public"."putenv"("text") RETURNS "void"
LANGUAGE "c" STRICT
AS '$libdir/regress.so', 'regress_putenv';
------
Regards,
Alexander Korotkov
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Use setenv() in preference to putenv().
@ 2020-12-31 03:08 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alexander Korotkov <aekorotkov@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2020-12-31 03:08 UTC (permalink / raw)
To: Alexander Korotkov <aekorotkov@gmail.com>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Alexander Korotkov <aekorotkov@gmail.com> writes:
> On Wed, Dec 30, 2020 at 8:56 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Use setenv() in preference to putenv().
> Recent buildfarm failure on crake seems to be related to this commit.
Yeah, see
https://www.postgresql.org/message-id/flat/2403475.1609360967%40sss.pgh.pa.us
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-12-31 03:08 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30 17:56 pgsql: Use setenv() in preference to putenv(). Tom Lane <tgl@sss.pgh.pa.us>
2020-12-31 02:51 ` Alexander Korotkov <aekorotkov@gmail.com>
2020-12-31 03:08 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox