Commit Graph

438 Commits

Author SHA1 Message Date
Tom Lane ea23ec82c2 Remove GUC USERLIMIT variable category, making the affected variables
plain SUSET instead.  Also delay processing of options received in
client connection request until after we know if the user is a superuser,
so that SUSET values can be set that way by legitimate superusers.
Per recent discussion.
2004-11-14 19:35:35 +00:00
Peter Eisentraut 3c093ff151 Clarify some error messages 2004-11-09 13:01:27 +00:00
Bruce Momjian 0c3663b47d Add comment to postmaster.c that get_progname() will call exit if it
can't strdup().
2004-11-02 03:34:50 +00:00
Tom Lane 380bd04c16 Standardize on using the Min, Max, and Abs macros that are in our c.h file,
getting rid of numerous ad-hoc versions that have popped up in various
places.  Shortens code and avoids conflict with Windows min() and max()
macros.
2004-10-21 19:28:36 +00:00
Bruce Momjian 8613eac6c4 Fix pg_ctl -D handling for Win32:
C:\msys\1.0\home\y-asaba>pg_ctl -D data restart
	waiting for postmaster to shut down...LOG:  received smart shutdown
	request.
	LOG:  shutting down
	LOG:  database system is shut down
	done
	postmaster stopped

	postmaster starting

	C:\msys\1.0\home\y-asaba>postmaster.exe: invalid argument: "'-D'"
	Try "postmaster.exe --help" for more information.

Yoshiyuki Asaba
2004-10-15 04:54:33 +00:00
Bruce Momjian 5c267325ec Add 'int' cast for getpid() because some Solaris releases return long
for getpid().
2004-10-14 20:23:46 +00:00
Peter Eisentraut 0fd37839d9 Message style revisions 2004-10-12 21:54:45 +00:00
Tom Lane 337ffcddba Adjust configuration-files GUC behavior as per my recent proposal.
The vars are renamed to data_directory, config_file, hba_file, and
ident_file, and are guaranteed to be set to accurate absolute paths
during postmaster startup.
This commit does not yet do anything about hiding path values from
non-superusers.
2004-10-09 23:13:22 +00:00
Tom Lane 7ca3a0f3e2 Whack some sense into the configuration-file-location patch.
Refactor code into something reasonably understandable, cause
use of the feature to not fail in standalone backends or in
EXEC_BACKEND case, fix sloppy guc.c table entries, make the
documentation minimally usable.
2004-10-08 01:36:36 +00:00
Bruce Momjian 9fb5c757b8 Remove unneeded dash. 2004-10-07 17:04:54 +00:00
Bruce Momjian 00f184a83f Update comment to fix nibble mention:
* We are not sure how much precision is in tv_usec, so we
	 * swap the high and low 16 bits of 'later' and XOR them with
	 * 'earlier'. On the off chance that the result is 0, we
	 * loop until it isn't.

Greg Stark
2004-10-07 17:03:50 +00:00
Tom Lane 52a45818a1 XOR process PID into a backend's initial random seed, to ensure that
different backends get a reasonably wide set of initial seeds even if
gettimeofday returns tv_usec values with only a few bits of precision.
Per recent discussion.
2004-10-07 00:03:15 +00:00
Bruce Momjian 902ca3e225 Here is a patch to fix win32 ssl builds. Summary of changes:
* Links with -leay32 and -lssleay32 instead of crypto and ssl. On win32,
"crypto and ssl" is only used for static linking.

* Initializes SSL in the backend and not just in the postmaster. We
cannot pass the SSL context from the postmaster through the parameter
file, because it contains function pointers.

* Split one error check in be-secure.c. Previously we could not tell
which of three calls actually failed. The previous code also returned
incorrect error messages if SSL_accept() failed - that function needs to
use SSL_get_error() on the return value, can't just use the error queue.

* Since the win32 implementation uses non-blocking sockets "behind the
scenes" in order to deliver signals correctly, implements a version of
SSL_accept() that can handle this. Also, add a wait function in case
SSL_read or SSL_write() needs more data.

Magnus Hagander
2004-10-06 09:35:23 +00:00
Bruce Momjian f1d1116178 Fix Cygwin defines to be consistent. 2004-09-09 00:59:49 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Bruce Momjian 466c1290df Fix for postmaster.c function win32_waitpid(int *exitstatus) call to
Win32 WaitForMultipleObjects:

	ret = WaitForMultipleObjects(win32_numChildren, win32_childHNDArray,
	FALSE, 0);

Problem is 'win32_numChildren' could be more then 64 ( function supports
), problem basically arise ( kills postgres ) when you create more then
64 connections and terminate some of them sill leaving more then 64.

Claudio Natoli
2004-08-29 03:16:30 +00:00
Tom Lane 33bf242a8a Make listen_addresses be a comma-separated list instead of a space-separated
list.  More consistent with our other list-containing GUC variables.
2004-08-08 20:17:36 +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
Tom Lane bb892cecf9 Tweak postmaster code to avoid double reporting when bgwriter crashes. 2004-08-04 20:09:47 +00:00
Tom Lane 5cc380f9a3 Error message style adjustments, per Alvaro Herrera. 2004-08-01 17:45:43 +00:00
Tom Lane a393fbf937 Restructure error handling as recently discussed. It is now really
possible to trap an error inside a function rather than letting it
propagate out to PostgresMain.  You still have to use AbortCurrentTransaction
to clean up, but at least the error handling itself will cooperate.
2004-07-31 00:45:57 +00:00
Tom Lane 0177f43070 Fix oversight: in case where SIGTERM is received while there are
live backends, the archiver and stats processes never got sent a
kill signal.  They'd eventually exit on their own, but not for awhile,
which is a bit annoying when you are trying to replace the executable
file on a platform that doesn't allow removal of busy executables.
Also, tweak main loop logic so that we will perform the background
tasks after select() returns EINTR.
2004-07-27 01:46:03 +00:00
Tom Lane 1e5d82493c Fix obsolete comment. 2004-07-24 20:01:42 +00:00
Bruce Momjian 7a55ba7615 Back out pg_autovacuum commit after cvs clean failure causes commit. 2004-07-21 20:34:50 +00:00
Bruce Momjian 8dec0c1bf2 lease find enclosed a patch that matches the PL/Perl documentation
(fairly closely, I hope) to the current PL/Perl implementation.

David Fetter
2004-07-21 20:23:05 +00:00
Tom Lane 66ec2db728 XLOG file archiving and point-in-time recovery. There are still some
loose ends and a glaring lack of documentation, but it basically works.

Simon Riggs with some editorialization by Tom Lane.
2004-07-19 02:47:16 +00:00
Bruce Momjian a4c71af2c0 Put back canonicalization of PGDATA environment variable. 2004-07-12 19:15:14 +00:00
Bruce Momjian 76e7e2e776 Use strdup in pg_ctl for canonicalize_path on environment variable.
Simplify postmaster call too.
2004-07-12 18:17:13 +00:00
Bruce Momjian 421089dc35 Cleanup for canonicalization fixes, from Tom. 2004-07-11 23:49:51 +00:00
Bruce Momjian 7b0f060d54 Use canonicalize_path for -D, GUC paths, and paths coming in from
environment variables.
2004-07-11 21:34:04 +00:00
Bruce Momjian 130f89e93f Allow configuration files to be placed outside the data directory.
Add new postgresql.conf variables to point to data, pg_hba.conf, and
pg_ident.conf files.

Needs more documentation.
2004-07-11 00:18:45 +00:00
Tom Lane 5dfd5063e2 Defend against overrun of ExtraOptions array --- strictly paranoia,
since the person or script starting the postmaster has to be trusted
anyway.
2004-07-10 23:29:16 +00:00
Tom Lane b15f9b08ef Replace direct fprintf(stderr) calls by write_stderr(), and cause this
routine to do something appropriate on Win32.  Also, add a security check
on Win32 that parallels the can't-run-as-root check on Unix.

Magnus Hagander
2004-06-24 21:03:42 +00:00
Tom Lane bbe42a1514 Arrange to explicitly stop the pgstat processes at the same time we
begin the shutdown checkpoint; there isn't anything left for them to do,
so we may as well ensure that they shut down sooner rather than later.
Per discussion.
2004-06-14 18:08:19 +00:00
Bruce Momjian 3a8cdf33aa >> It certainly doesn't. There still was a bug with the locale stuff,
>> though - the GUC variable was not set in the child
>processes. So "show
>> lc_collate" would *always* return "C", for example. attached
>patch fixes
>> this.
>
>Hm.  Why were these vars not propagated by the regular
>mechanism for GUC
>variables (write_nondefault_variables or whatever it's called)?  If the
>problem is that it's not accepting PGC_INTERNAL values, then we need to
>fix it there not here, because otherwise we'll have to pass all the
>PGC_INTERNAL variables through the backend_variables file, which seems
>like a recipe for more of the same sort of bug.


Good point :-(

I think the problem is not only that it specifically does not deal with
PGC_INTERNAL variables. The problem is in the fact that
write_nondefault_variables is called *before* the locale is read
(because the locale is read from pg_control and not from any of the
"usual" ways to read it).

Attached patch is another stab at fixing it. It makes postmaster dump a
new copy of the file once it has started the database (before it accepts
any connections), which is when it will know about these parameters.
Also updates the reading code to set the context to the one where the
variable was originally set (PGC_POSTMASTER won't work for PGC_INTERNAL,
and the other way around).

We still pass lc_collate through the special file, because
set_config_option on lc_collate will speficially *not* call setlocale(),
and we need that call. But we no longer call set_config_option from
there.

Magnus Hagander
2004-06-11 03:54:54 +00:00
Tom Lane 921d749bd4 Adjust our timezone library to use pg_time_t (typedef'd as int64) in
place of time_t, as per prior discussion.  The behavior does not change
on machines without a 64-bit-int type, but on machines with one, which
is most, we are rid of the bizarre boundary behavior at the edges of
the 32-bit-time_t range (1901 and 2038).  The system will now treat
times over the full supported timestamp range as being in your local
time zone.  It may seem a little bizarre to consider that times in
4000 BC are PST or EST, but this is surely at least as reasonable as
propagating Gregorian calendar rules back that far.

I did not modify the format of the zic timezone database files, which
means that for the moment the system will not know about daylight-savings
periods outside the range 1901-2038.  Given the way the files are set up,
it's not a simple decision like 'widen to 64 bits'; we have to actually
think about the range of years that need to be supported.  We should
probably inquire what the plans of the upstream zic people are before
making any decisions of our own.
2004-06-03 02:08:07 +00:00
Tom Lane c6719a2784 Implement new PostmasterIsAlive() check for WIN32, per Claudio Natoli.
In passing, align a few error messages with the style guide.
2004-05-30 03:50:15 +00:00
Tom Lane 076a055acf Separate out bgwriter code into a logically separate module, rather
than being random pieces of other files.  Give bgwriter responsibility
for all checkpoint activity (other than a post-recovery checkpoint);
so this child process absorbs the functionality of the former transient
checkpoint and shutdown subprocesses.  While at it, create an actual
include file for postmaster.c, which for some reason never had its own
file before.
2004-05-29 22:48:23 +00:00
Tom Lane 1b9ef0025d Fix some typos I introduced in WIN32-only code late last night.
Thanks to Thomas Hallgren.
2004-05-28 15:14:03 +00:00
Tom Lane 1a321f26d8 Code review for EXEC_BACKEND changes. Reduce the number of #ifdefs by
about a third, make it work on non-Windows platforms again.  (But perhaps
I broke the WIN32 code, since I have no way to test that.)  Fold all the
paths that fork postmaster child processes to go through the single
routine SubPostmasterMain, which takes care of resurrecting the state that
would normally be inherited from the postmaster (including GUC variables).
Clean up some places where there's no particularly good reason for the
EXEC and non-EXEC cases to work differently.  Take care of one or two
FIXMEs that remained in the code.
2004-05-28 05:13:32 +00:00
Tom Lane 16974ee910 Get rid of the former rather baroque mechanism for propagating the values
of ThisStartUpID and RedoRecPtr into new backends.  It's a lot easier just
to make them all grab the values out of shared memory during startup.
This helps to decouple the postmaster from checkpoint execution, which I
need since I'm intending to let the bgwriter do it instead, and it also
fixes a bug in the Win32 port: ThisStartUpID wasn't getting propagated at
all AFAICS.  (Doesn't give me a lot of faith in the amount of testing that
port has gotten.)
2004-05-27 17:12:57 +00:00
Bruce Momjian bb44a7c525 pgindent files for Tom. 2004-05-27 15:07:41 +00:00
Bruce Momjian 97d625dd1c *) inet_(client|server)_(addr|port)() and necessary documentation for
the four functions.


> Also, please justify the temp-related changes.  I was not aware that we
> had any breakage there.

patch-tmp-schema.txt contains the following bits:

*) Changes pg_namespace_aclmask() so that the superuser is always able
to create objects in the temp namespace.
*) Changes pg_namespace_aclmask() so that if this is a temp namespace,
objects are only allowed to be created in the temp namespace if the
user has TEMP privs on the database.  This encompasses all object
creation, not just TEMP tables.
*) InitTempTableNamespace() checks to see if the current user, not the
session user, has access to create a temp namespace.

The first two changes are necessary to support the third change.  Now
it's possible to revoke all temp table privs from non-super users and
limiting all creation of temp tables/schemas via a function that's
executed with elevated privs (security definer).  Before this change,
it was not possible to have a setuid function to create a temp
table/schema if the session user had no TEMP privs.

patch-area-path.txt contains:

*) Can now determine the area of a closed path.


patch-dfmgr.txt contains:

*) Small tweak to add the library path that's being expanded.

I was using $lib/foo.so and couldn't easily figure out what the error
message, "invalid macro name in dynamic library path" meant without
looking through the source code.  With the path in there, at least I
know where to start looking in my config file.

Sean Chittenden
2004-05-26 18:35:51 +00:00
Tom Lane ebfc56d3fb Handle impending sinval queue overflow by means of a separate signal
(SIGUSR1, which we have not been using recently) instead of piggybacking
on SIGUSR2-driven NOTIFY processing.  This has several good results:
the processing needed to drain the sinval queue is a lot less than the
processing needed to answer a NOTIFY; there's less contention since we
don't have a bunch of backends all trying to acquire exclusive lock on
pg_listener; backends that are sitting inside a transaction block can
still drain the queue, whereas NOTIFY processing can't run if there's
an open transaction block.  (This last is a fairly serious issue that
I don't think we ever recognized before --- with clients like JDBC that
tend to sit with open transaction blocks, the sinval queue draining
mechanism never really worked as intended, probably resulting in a lot
of useless cache-reset overhead.)  This is the last of several proposed
changes in response to Philip Warner's recent report of sinval-induced
performance problems.
2004-05-23 03:50:45 +00:00
Tom Lane 63bd0db121 Integrate src/timezone library for all platforms. There is more we can
and should do now that we control our own destiny for timezone handling,
but this commit gets the bulk of the picayune diffs in place.
Magnus Hagander and Tom Lane.
2004-05-21 05:08:06 +00:00
Bruce Momjian 9ee3310768 Add get_pkglib_path to postmaster.c 2004-05-19 19:11:25 +00:00
Bruce Momjian 5a7e1a187c Move find_my_exec lower so elog() works, per Tom. 2004-05-19 18:58:44 +00:00
Bruce Momjian eb79aea9ed Move get_pkglib_path up into main.c too. 2004-05-18 20:27:25 +00:00
Bruce Momjian a9fad44372 Move find_my_exec() way up into main.c so it is available to the
timezone code and other places.

Remove elog() calls from find_my_exec;  do fprintf(stderr) instead.  We
can then remove the exec.c handling in the makefile because it doesn't
have to be built to suppress elog calls.
2004-05-18 20:18:59 +00:00