aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/misc.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-08-12 03:25:13 +0000
committerBruce Momjian <bruce@momjian.us>2005-08-12 03:25:13 +0000
commitb609695b7a5c1cf7c1234143eeb35809d00ff741 (patch)
treee8777cf8e513d49c0e30cc5fd0f8d793115c141a /src/backend/utils/adt/misc.c
parentd95886e7340b3812bbe30098da053f4d167b34a5 (diff)
downloadpostgresql-b609695b7a5c1cf7c1234143eeb35809d00ff741.tar.gz
postgresql-b609695b7a5c1cf7c1234143eeb35809d00ff741.zip
Add files to do read I/O on the cluster directory:
pg_stat_file() pg_read_file() pg_ls_dir() pg_reload_conf() pg_rotate_logfile() Dave Page Andreas Pflug
Diffstat (limited to 'src/backend/utils/adt/misc.c')
-rw-r--r--src/backend/utils/adt/misc.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 867f7da7e2a..40b4c64cd12 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.45 2005/07/04 04:51:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.46 2005/08/12 03:24:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,14 +21,23 @@
#include "commands/dbcommands.h"
#include "miscadmin.h"
#include "storage/procarray.h"
+#include "storage/pmsignal.h"
#include "storage/fd.h"
#include "utils/builtins.h"
+#include "utils/elog.h"
#include "funcapi.h"
#include "catalog/pg_type.h"
#include "catalog/pg_tablespace.h"
+#include "postmaster/syslogger.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
+typedef struct
+{
+ char *location;
+ DIR *dirdesc;
+} directory_fctx;
+
/*
* Check if data is Null
@@ -107,6 +116,51 @@ pg_cancel_backend(PG_FUNCTION_ARGS)
PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0), SIGINT));
}
+
+Datum
+pg_reload_conf(PG_FUNCTION_ARGS)
+{
+ if (!superuser())
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("must be superuser to signal the postmaster"))));
+
+ if (kill(PostmasterPid, SIGHUP))
+ {
+ ereport(WARNING,
+ (errmsg("failed to send signal to postmaster: %m")));
+
+ PG_RETURN_INT32(0);
+ }
+
+ PG_RETURN_INT32(1);
+}
+
+
+/*
+ * Rotate log file
+ */
+Datum
+pg_rotate_logfile(PG_FUNCTION_ARGS)
+{
+ if (!superuser())
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("must be superuser to rotate log files"))));
+
+ if (!Redirect_stderr)
+ {
+ ereport(NOTICE,
+ (errcode(ERRCODE_WARNING),
+ errmsg("no logfile configured; rotation not supported")));
+ PG_RETURN_INT32(0);
+ }
+
+ SendPostmasterSignal(PMSIGNAL_ROTATE_LOGFILE);
+
+ PG_RETURN_INT32(0);
+}
+
#ifdef NOT_USED
/* Disabled in 8.0 due to reliability concerns; FIXME someday */