aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2014-07-22 11:01:03 -0400
committerNoah Misch <noah@leadboat.com>2014-07-22 11:01:03 -0400
commitd7cdf6ee36adeac9233678fb8f2a112e6678a770 (patch)
tree1f2c0717280027b904f6bfa92569ce0534b7e157 /src
parent24e786f056c0bf009815813de1d7f58ee09f554e (diff)
downloadpostgresql-d7cdf6ee36adeac9233678fb8f2a112e6678a770.tar.gz
postgresql-d7cdf6ee36adeac9233678fb8f2a112e6678a770.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/regress.c43
1 files changed, 43 insertions, 0 deletions
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 <float.h>
#include <math.h>
+#include <signal.h>
#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();
+}