Skip site navigation (1) Skip section navigation (2)

logfile subprocess and Fancy File Functions

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>,Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: logfile subprocess and Fancy File Functions
Date: 2004-07-17 19:56:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
The attached patch and additional src/backend/postmaster/syslogger.c 
implements the logfile subprocess as discussed.

- documentation
- win32 code (forkexec) is included, but not tested (no build env)

Functions (all are superuser only):

int4 pg_reload_conf()
Sends SIGHUP to postmaster

bool pg_logfile_rotate()
initiates logfile rotation, same does SIGUSR1 to the syslogger 
subprocess; returns true if logging is enabled

setof record pg_logfiles_ls()
lists all available logfiles, should we have a view as well?
CREATE VIEW pg_logfiles AS
SELECT ts, pid, fn
   FROM pg_logfiles_ls()
        AS pgls(ts timestamp, pid int4, fn text)

int8 pg_file_length(filename_text)
returns length of file, or -1 if non existent (no ERROR)

text pg_file_read(filename_text, startpos_int6, length_int8)
reads file

int8 pg_file_write(filename_text, data_text, append_bool)
writes file. creates or appends
to create, file must not exist, to append, file may exist.

bool pg_file_rename(filename_old_text, filenamenew_text)
rename file

bool pg_file_unlink(filename_text)
unlinks file. returns true/false if done (no ERROR)

bool pg_file_rename(filename_old_text,
	filename_new_text, filename_archive_text)
chain rename: new->archive, old->archive, example:

It should be quite safe to do

	'.....some stuff...', false);
	'postgresql.conf', 'postgresql.conf.bak');


Attachment: syslogger.c
Description: text/x-csrc (13.1 KB)
Attachment: logfile.diff
Description: text/x-patch (24.7 KB)


pgsql-patches by date

Next:From: Bruce MomjianDate: 2004-07-17 20:15:21
Subject: Re: [HACKERS] Point in Time Recovery
Previous:From: Tom LaneDate: 2004-07-17 19:22:17
Subject: Re: Subtransaction documentation

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group