From d7cdf6ee36adeac9233678fb8f2a112e6678a770 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Tue, 22 Jul 2014 11:01:03 -0400 Subject: Diagnose incompatible OpenLDAP versions during build and test. With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, PostgreSQL backends can crash at exit. Raise a warning during "configure" based on the compile-time OpenLDAP version number, and test the crash scenario in the dblink test suite. Back-patch to 9.0 (all supported versions). --- src/test/regress/regress.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src') diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index c1461092fb3..09e027c1e5b 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -6,6 +6,7 @@ #include #include +#include #include "access/htup_details.h" #include "access/transam.h" @@ -16,6 +17,7 @@ #include "commands/trigger.h" #include "executor/executor.h" #include "executor/spi.h" +#include "miscadmin.h" #include "utils/builtins.h" #include "utils/geo_decls.h" #include "utils/rel.h" @@ -822,3 +824,44 @@ make_tuple_indirect(PG_FUNCTION_ARGS) */ PG_RETURN_POINTER(newtup->t_data); } + +PG_FUNCTION_INFO_V1(regress_putenv); + +Datum +regress_putenv(PG_FUNCTION_ARGS) +{ + MemoryContext oldcontext; + char *envbuf; + + if (!superuser()) + elog(ERROR, "must be superuser to change environment variables"); + + oldcontext = MemoryContextSwitchTo(TopMemoryContext); + envbuf = text_to_cstring((text *) PG_GETARG_POINTER(0)); + MemoryContextSwitchTo(oldcontext); + + if (putenv(envbuf) != 0) + elog(ERROR, "could not set environment variable: %m"); + + PG_RETURN_VOID(); +} + +/* Sleep until no process has a given PID. */ +PG_FUNCTION_INFO_V1(wait_pid); + +Datum +wait_pid(PG_FUNCTION_ARGS) +{ + int pid = PG_GETARG_INT32(0); + + if (!superuser()) + elog(ERROR, "must be superuser to check PID liveness"); + + while (kill(pid, 0) == 0) + pg_usleep(50000); + + if (errno != ESRCH) + elog(ERROR, "could not check PID %d liveness: %m", pid); + + PG_RETURN_VOID(); +} -- cgit v1.2.3