mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
7ca37fb040
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
15 lines
415 B
Plaintext
15 lines
415 B
Plaintext
-- Initialization that requires path substitution.
|
|
|
|
CREATE FUNCTION setenv(text, text)
|
|
RETURNS void
|
|
AS '@libdir@/regress@DLSUFFIX@', 'regress_setenv'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION wait_pid(int)
|
|
RETURNS void
|
|
AS '@libdir@/regress@DLSUFFIX@'
|
|
LANGUAGE C STRICT;
|
|
|
|
CREATE FUNCTION set_pgservicefile(text) RETURNS void LANGUAGE SQL
|
|
AS $$SELECT setenv('PGSERVICEFILE', '@abs_srcdir@/' || $1)$$;
|