Commit Graph

138 Commits

Author SHA1 Message Date
Tom Lane 25a4a77985 Suppress uninitialized-variable warning. 2007-08-21 01:47:19 +00:00
Andrew Dunstan fd801f4faa Provide for logfiles in machine readable CSV format. In consequence, rename
redirect_stderr to logging_collector.
Original patch from Arul Shaji, subsequently modified by Greg Smith, and then
heavily modified by me.
2007-08-19 01:41:25 +00:00
Tom Lane bdd6b62245 Switch over to using the src/timezone functions for formatting timestamps
displayed in the postmaster log.  This avoids Windows-specific problems with
localized time zone names that are in the wrong encoding, and generally seems
like a good idea to forestall other potential platform-dependent issues.
To preserve the existing behavior that all backends will log in the same time
zone, create a new GUC variable log_timezone that can only be changed on a
system-wide basis, and reference log-related calculations to that zone instead
of the TimeZone variable.

This fixes the issue reported by Hiroshi Saito that timestamps printed by
xlog.c startup could be improperly localized on Windows.  We still need a
simpler patch for that problem in the back branches, however.
2007-08-04 01:26:54 +00:00
Andrew Dunstan 63872601e8 Move session_start out of MyProcPort stucture and make it a global called MyStartTime,
so that we will be able to create a cookie for all processes for CSVlogs.
It is set wherever MyProcPid is set. Take the opportunity to remove the now
unnecessary session-only restriction on the %s and %c escapes in log_line_prefix.
2007-08-02 23:39:45 +00:00
Andrew Dunstan b34903453f Make sure syslogPipe runs in binary mode on Windows to avoid corrupting the pipe chunking protocol. Backport to 8.0 2007-08-02 23:15:27 +00:00
Andrew Dunstan 0e5b4f0e23 Only use the pipe chunking protocol if we know the syslogger should
be catching stderr output, and we are not ourselves the
syslogger. Otherwise, go directly to stderr.
Bug noticed by Tom Lane.
Backpatch as far as 8.0.
2007-07-19 19:13:43 +00:00
Andrew Dunstan bd2cb9aaa5 Implement a chunking protocol for writes to the syslogger pipe, with messages
reassembled in the syslogger before writing to the log file. This prevents
partial messages from being written, which mucks up log rotation, and
messages from different backends being interleaved, which causes garbled
logs. Backport as far as 8.0, where the syslogger was introduced.

Tom Lane and Andrew Dunstan
2007-06-14 01:48:51 +00:00
Andrew Dunstan 4c0fe51279 Remove ill-conceived CRLF translation for Windows in syslogger. 2007-06-04 22:21:42 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Tom Lane 3ad0728c81 On systems that have setsid(2) (which should be just about everything except
Windows), arrange for each postmaster child process to be its own process
group leader, and deliver signals SIGINT, SIGTERM, SIGQUIT to the whole
process group not only the direct child process.  This provides saner behavior
for archive and recovery scripts; in particular, it's possible to shut down a
warm-standby recovery server using "pg_ctl stop -m immediate", since delivery
of SIGQUIT to the startup subprocess will result in killing the waiting
recovery_command.  Also, this makes Query Cancel and statement_timeout apply
to scripts being run from backends via system().  (There is no support in the
core backend for that, but it's widely done using untrusted PLs.)  Per gripe
from Stephen Harris and subsequent discussion.
2006-11-21 20:59:53 +00:00
Tom Lane 93120f3501 In a Windows backend, don't build src/port/pgsleep.c's version of
pg_usleep at all.  Instead call the replacement function in
port/win32/signal.c by that name.  Avoids tricky macro-redefinition
logic and suppresses a compiler warning; furthermore it ensures that
no one can accidentally use the non-signal-aware version of pg_usleep
in a Windows backend.
2006-07-16 20:17:04 +00:00
Bruce Momjian ac230e7431 Alphabetically order reference to include files, "S"-"Z". 2006-07-11 18:26:11 +00:00
Bruce Momjian 370a709c75 Add GUC update_process_title to control whether 'ps' display is updated
for every command, default to on.
2006-06-27 22:16:44 +00:00
Peter Eisentraut 5266f221a2 Merge postmaster and postgres command into just postgres. postmaster
symlink is kept for now for compatibility.  To call single-user mode, use
postgres --single.
2006-06-18 15:38:37 +00:00
Bruce Momjian 399a36a75d Prepare code to be built by MSVC:
o  remove many WIN32_CLIENT_ONLY defines
	o  add WIN32_ONLY_COMPILER define
	o  add 3rd argument to open() for portability
	o  add include/port/win32_msvc directory for
	   system includes

Magnus Hagander
2006-06-07 22:24:46 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Tom Lane 349f40b2c2 Rearrange backend startup sequence so that ShmemIndexLock can become
an LWLock instead of a spinlock.  This hardly matters on Unix machines
but should improve startup performance on Windows (or any port using
EXEC_BACKEND).  Per previous discussion.
2006-01-04 21:06:32 +00:00
Bruce Momjian 436a2956d8 Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
2005-11-22 18:17:34 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Bruce Momjian b609695b7a 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
2005-08-12 03:25:13 +00:00
Bruce Momjian e6b72d6af6 Update DAYS_PER_MONTH comment.
Add SECS_PER_YEAR and MINS_PER_HOUR macros.
2005-07-21 18:06:13 +00:00
Bruce Momjian a536b2dd80 Add time/date macros for code clarity:
#define DAYS_PER_YEAR   365.25
	#define MONTHS_PER_YEAR 12
	#define DAYS_PER_MONTH  30
	#define HOURS_PER_DAY   24
2005-07-21 03:56:25 +00:00
Tom Lane eb5949d190 Arrange for the postmaster (and standalone backends, initdb, etc) to
chdir into PGDATA and subsequently use relative paths instead of absolute
paths to access all files under PGDATA.  This seems to give a small
performance improvement, and it should make the system more robust
against naive DBAs doing things like moving a database directory that
has a live postmaster in it.  Per recent discussion.
2005-07-04 04:51:52 +00:00
Bruce Momjian aa8bdab272 Attached patch gets rid of the global timezone in the following steps:
* Changes the APIs to the timezone functions to take a pg_tz pointer as
an argument, representing the timezone to use for the selected
operation.

* Adds a global_timezone variable that represents the current timezone
in the backend as set by SET TIMEZONE (or guc, or env, etc).

* Implements a hash-table cache of loaded tables, so we don't have to
read and parse the TZ file everytime we change a timezone. While not
necesasry now (we don't change timezones very often), I beleive this
will be necessary (or at least good) when "multiple timezones in the
same query" is eventually implemented. And code-wise, this was the time
to do it.


There are no user-visible changes at this time. Implementing the
"multiple zones in one query" is a later step...

This also gets rid of some of the cruft needed to "back out a timezone
change", since we previously couldn't check a timezone unless it was
activated first.

Passes regression tests on win32, linux (slackware 10) and solaris x86.

Magnus Hagander
2005-04-19 03:13:59 +00:00
Tom Lane a214e9c996 Fix problem with infinite recursion between write_syslogger_file and
elog if the former has trouble writing its file.  Code review for
Magnus' patch to redirect stderr to syslog on Windows (Bruce's version
seems right, but did some minor prettification).

Backpatch both changes to 8.0 branch.
2005-03-12 01:54:44 +00:00
Neil Conway 164adc4d39 Refactor fork()-related code. We need to do various housekeeping tasks
before we can invoke fork() -- flush stdio buffers, save and restore the
profiling timer on Linux with LINUX_PROFILE, and handle BeOS stuff. This
patch moves that code into a single function, fork_process(), instead of
duplicating it at the various callsites of fork().

This patch doesn't address the EXEC_BACKEND case; there is room for
further cleanup there.
2005-03-10 07:14:03 +00:00
Tom Lane 7e1c8ef4fc Some more missed copyright notices. Many of these look like they
should have been caught by the src/tools/copyright script ... why
weren't they?
2005-01-01 20:44:34 +00:00
Peter Eisentraut 3c093ff151 Clarify some error messages 2004-11-09 13:01:27 +00:00
Peter Eisentraut 0fd37839d9 Message style revisions 2004-10-12 21:54:45 +00:00
Tom Lane 95f20b96d4 Rotate on time boundaries that are sensible per local time rather than GMT.
Also, avoid truncating the file we just wrote into, which might otherwise
easily happen at DST boundaries.  Ed L. and Tom Lane.
2004-09-21 00:21:25 +00:00
Tom Lane 8c603f2c95 Replace log_filename_prefix with more general log_filename parameter,
to allow DBA to choose the form in which log filenames reflect the
current time.  Also allow for truncating instead of appending to
pre-existing files --- this is convenient when the log filename pattern
rewrites the same names cyclically.  Per Ed L.
2004-08-31 04:53:44 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian 704ff0b2f2 >>> I understand your disliking of non-posix stuff. OTOH,
>>GetLastError will
>>> give much more details than errno.
>>
>>How much more, really?  That mapping table gave me the impression that
>>the win32 error codes aren't all that much more detailed than errno...
>
>The mapping table is not complete. My winerror.h from the SDK
>lists 2209
>error codes, whereas errno.h lists 42...
>
>I still don't think we'll get that much more stuff. Right now,
>the Win32
>code paths that actually use the more advanced functions already write
>out the error number in case something happens. We can keep doing that
>for the other paths (ereport the error *number* when the mapping does
>not have a match). The map to errno will catch almost all cases, I
>think. And in the corner cases we can do with just the number, and use
>"net helpmsg" to get the actual message when checking...

Here's an attempt on this. new file goes in backend/port/win32.

Magnus Hagander
2004-08-29 00:38:03 +00:00
Tom Lane 8cf8b47a21 syslogger.c needs <sys/time.h> on some platforms, per Greg Mullane. 2004-08-09 20:28:48 +00:00
Tom Lane 220ec930fc Arrange for proper newline termination of syslogger's own messages,
per Andreas.
2004-08-06 19:17:31 +00:00
Tom Lane 533bd1d5a7 Add _O_TEXT option to dup2 call on Windows, to ensure redirected postmaster
stderr is in text mode.  Per Andreas.
2004-08-06 16:06:59 +00:00
Tom Lane 8ae7278ced Fix several small Windows compatibility issues, per Andreas. 2004-08-06 16:00:51 +00:00
Tom Lane bdf8ef6925 Create a built-in log rotation program, so that we no longer have to
recommend that people go get Apache's rotatelogs program.  Additional
benefits are that configuration is done through GUC, rather than
externally, and that the postmaster can monitor the log rotator and
restart it after failure (though we certainly hope that won't happen
often).
Andreas Pflug, some rework by Tom Lane.
2004-08-05 23:32:13 +00:00