mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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).
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "access/transam.h"
|
||||
#include "access/xact.h"
|
||||
@ -14,8 +15,10 @@
|
||||
#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/memutils.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
|
||||
@ -35,6 +38,8 @@ extern char *reverse_name(char *string);
|
||||
extern int oldstyle_length(int n, text *t);
|
||||
extern Datum int44in(PG_FUNCTION_ARGS);
|
||||
extern Datum int44out(PG_FUNCTION_ARGS);
|
||||
extern Datum regress_putenv(PG_FUNCTION_ARGS);
|
||||
extern Datum wait_pid(PG_FUNCTION_ARGS);
|
||||
|
||||
#ifdef PG_MODULE_MAGIC
|
||||
PG_MODULE_MAGIC;
|
||||
@ -737,3 +742,44 @@ int44out(PG_FUNCTION_ARGS)
|
||||
*--walk = '\0';
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user