Commit Graph

11007 Commits

Author SHA1 Message Date
Tom Lane f784f05e95 Clear error_context_stack and debug_query_string at the beginning of proc_exit,
so that we won't try to attach any context printouts to messages that get
emitted while exiting.  Per report from Dennis Koegel, the context functions
won't necessarily work after we've started shutting down the backend, and it
seems possible that debug_query_string could be pointing at freed storage
as well.  The context information doesn't seem particularly relevant to
such messages anyway, so there's little lost by suppressing it.

Back-patch to all supported branches.  I can only demonstrate a crash with
log_disconnections messages back to 8.1, but the risk seems real in 8.0 and
before anyway.
2010-03-20 00:58:09 +00:00
Robert Haas acdd6ea5ab Forbid renaming columns of objects whose column names are system-generated.
KaiGai Kohei, with adjustments to the comments.
2010-03-20 00:43:42 +00:00
Tom Lane a836abe9f6 Modify error context callback functions to not assume that they can fetch
catalog entries via SearchSysCache and related operations.  Although, at the
time that these callbacks are called by elog.c, we have not officially aborted
the current transaction, it still seems rather risky to initiate any new
catalog fetches.  In all these cases the needed information is readily
available in the caller and so it's just a matter of a bit of extra notation
to pass it to the callback.

Per crash report from Dennis Koegel.  I've concluded that the real fix for
his problem is to clear the error context stack at entry to proc_exit, but
it still seems like a good idea to make the callbacks a bit less fragile
for other cases.

Backpatch to 8.4.  We could go further back, but the patch doesn't apply
cleanly.  In the absence of proof that this fixes something and isn't just
paranoia, I'm not going to expend the effort.
2010-03-19 22:54:41 +00:00
Simon Riggs 6a771d1d36 Add connection messages for streaming replication. log_connections
was broken for a replication connection and no messages were
displayed on either standby or primary, at any debug level.
Connection messages needed to diagnose session drop/reconnect
events. Use LOG mode for now, discuss lowering in later releases.
2010-03-19 19:19:38 +00:00
Simon Riggs 75867c528d Minor tweaks on libpqrcv_connect(): ensure conninfo_repl[] is
correctly sized and expand comment to explain otherwise
undocumented use of replication connection parameter.
2010-03-19 17:51:42 +00:00
Simon Riggs 3cdafe40e7 Adjust comment in .history file to match recovery target specified. Comment
present since 8.0 was never fully meaningful, since two recovery targets
cannot be specified. Refactor recovery target type to make this change
and associated code easier to understand. No change in function.

Bug report arising from internal support question.
2010-03-19 11:05:15 +00:00
Simon Riggs 5c73ae17d1 Reset btpo.xact following recovery of btree delete page. Add btpo_xact
field into WAL record and reset it from there, rather than using
FrozenTransactionId which can lead to some corner case bugs.

Problem report and suggested route to a fix from Heikki, details by me.
2010-03-19 10:41:22 +00:00
Heikki Linnakangas c21ac0b58e Add restartpoint_command option to recovery.conf. Fix bug in %r handling
in recovery_end_command, it always came out as 0 because InRedo was
cleared before recovery_end_command was executed. Also, always take
ControlFileLock when reading checkpoint location for %r.

The recovery_end_command bug and the missing locking was present in 8.4
as well, that part of this patch will be backported separately.
2010-03-18 09:17:18 +00:00
Simon Riggs 6407fa996a Add vacuum_defer_cleanup_age to postgresql.conf.sample. 2010-03-18 07:01:01 +00:00
Tom Lane 93324355eb Pass incompletely-transformed aggregate argument lists as separate parameters
to transformAggregateCall, instead of abusing fields in Aggref to carry them
temporarily.  No change in functionality but hopefully the code is a bit
clearer now.  Per gripe from Gokulakannan Somasundaram.
2010-03-17 16:52:38 +00:00
Heikki Linnakangas a383c55a1d Throw a nicer error message if a standby server attempts to connect while
the master is still in recovery. We don't support cascading slaves yet.

Patch by Fujii Masao, with slightly changed wording.
2010-03-16 09:09:55 +00:00
Simon Riggs 1a163a0c68 Remove incorrect comment from GetWriteRecPtr(): the return value is always
correct, as described in comments at start of xlog.c
2010-03-15 18:49:17 +00:00
Bruce Momjian 54aaef8642 Revert all keepalive moves, reevaluate. 2010-03-13 16:56:37 +00:00
Bruce Momjian 3f10d21ecd Move more tcp keepalive macros to be consistent. 2010-03-13 16:40:38 +00:00
Bruce Momjian 45d9d90c83 Move TCP keepalive macro definition
Jaime Casanova
2010-03-13 15:35:46 +00:00
Bruce Momjian a6c1cea2b7 Add libpq warning message if the .pgpass-retrieved password fails.
Add ERRCODE_INVALID_PASSWORD sqlstate error code.
2010-03-13 14:55:57 +00:00
Bruce Momjian 89b0095ebd Allow underscores in tsearch email addressses, per RFC 5322 and report
by Dan O'Hara.

Patch by Teodor Sigaev
2010-03-13 00:41:58 +00:00
Tom Lane 52e2b33a55 Add some logging code for unexpected cases in pgstat.c, particularly being
unable to read a stats file for reasons other than ENOENT, and having to reset
last_statrequest because it's later than current time in the collector.
Not clear if this will shed any light on the "pgstat wait timeout" business,
but it seems like a good idea in general.

In passing, do some message-style-police work on recently-added
pgstat_reset_shared_counters code.
2010-03-12 22:19:19 +00:00
Tom Lane 1f44a313bd Add missing reset of need_initialization in reloptions code.
This resulted in useless extra work during every call of parseRelOptions,
but no bad effects other than that.  Noted by Alvaro.
2010-03-11 21:47:19 +00:00
Heikki Linnakangas e0f9e2b648 Fix bug in KnownAssignedXidsMany(). I saw this when looking at the
assertion failure reported by Erik Rijkers, but this alone doesn't explain
the failure.
2010-03-11 09:26:59 +00:00
Heikki Linnakangas daaeac88aa Fix comment which was apparently copy-pasted from another function. 2010-03-11 09:10:25 +00:00
Robert Haas 70aedc0c55 Fix incorrect comment about permissions checking being done in utility.c.
Noted while reviewing a patch from KaiGai Kohei.
2010-03-10 19:48:39 +00:00
Itagaki Takahiro 17d8de0e61 pg_start_backup() can use a share lock to lock ControlFileLock
instead of an exclusive lock.

The change is almost for code cleanup. Since there seems to be no
performance benefits from it, backports should not be needed.

Fujii Masao
2010-03-10 02:04:48 +00:00
Magnus Hagander 6c6ee75ad3 Disallow gssapi authentication on local connections, since it
requires a hostname to function.

Noted by Zdenek Kotala
2010-03-08 09:57:26 +00:00
Tom Lane 153012c7d1 Fix warning messages in restrict_and_check_grant() to include the column name
when warning about column-level privileges.  This is more useful than before
and makes the apparent duplication complained of by Piyush Newe not so
duplicate.  Also fix lack of quote marks in a related message text.

Back-patch to 8.4, where column-level privileges were introduced.

Stephen Frost
2010-03-06 23:10:42 +00:00
Tom Lane b8b34b7b44 When reading pg_hba.conf and similar files, do not treat @file as an inclusion
unless (1) the @ isn't quoted and (2) the filename isn't empty.  This guards
against unexpectedly treating usernames or other strings in "flat files"
as inclusion requests, as seen in a recent trouble report from Ed L.
The empty-filename case would be guaranteed to misbehave anyway, because our
subsequent path-munging behavior results in trying to read the directory
containing the current input file.

I think this might finally explain the report at
http://archives.postgresql.org/pgsql-bugs/2004-05/msg00132.php
of a crash after printing "authentication file token too long, skipping",
since I was able to duplicate that message (though not a crash) on a
platform where stdio doesn't refuse to read directories.  We never got
far in investigating that problem, but now I'm suspicious that the trigger
condition was an @ in the flat password file.

Back-patch to all active branches since the problem can be demonstrated in all
branches except HEAD.  The test case, creating a user named "@", doesn't cause
a problem in HEAD since we got rid of the flat password file.  Nonetheless it
seems like a good idea to not consider quoted @ as a file inclusion spec,
so I changed HEAD too.
2010-03-06 00:45:49 +00:00
Heikki Linnakangas 3bdede3974 Fix IsBinaryCoercible to not confuse a cast using in/out functions
with binary compatibility.

Backpatch to 8.4 where INOUT casts were introduced.
2010-03-04 09:39:53 +00:00
Bruce Momjian ea066f87c3 Document that "Q" is ignored by to_date and to_timestamp. Add C comment
about the behavior.

Document that quotes in to_date, to_timestamp, to_number skip input
characters.
2010-03-03 22:28:42 +00:00
Tom Lane 61d75116a7 Fix a couple of places that would loop forever if attempts to read a stdio file
set ferror() but never set feof().  This is known to be the case for recent
glibc when trying to read a directory as a file, and might be true for other
platforms/cases too.  Per report from Ed L.  (There is more that we ought to
do about his report, but this is one easily identifiable issue.)
2010-03-03 20:31:09 +00:00
Tom Lane 8bf14182cf Export xml.c's libxml-error-handling support so that contrib/xml2 can use it
too, instead of duplicating the functionality (badly).

I renamed xml_init to pg_xml_init, because the former seemed just a bit too
generic to be safe as a global symbol.  I considered likewise renaming
xml_ereport to pg_xml_ereport, but felt that the reference to ereport probably
made it sufficiently PG-centric already.
2010-03-03 17:29:45 +00:00
Magnus Hagander 8373490607 It's clearly now pointless to do backwards compatible parsing of this,
since we released a version without it, so remove the comment that
says we might want to do that.
2010-03-01 16:02:01 +00:00
Tom Lane 4d17a2146c Insert a hack into get_float8_nan (both core and ecpg copies) to deal with
the fact that NetBSD/mips is currently broken, as per buildfarm member pika.

Also add regression tests to ensure that get_float8_nan and get_float4_nan
are exercised even on platforms where they are not needed by
float8in/float4in.

Zoltán Böszörményi and Tom Lane
2010-02-27 21:53:21 +00:00
Bruce Momjian bf379837dc Back out unintended change to pg_locale.c. 2010-02-27 20:20:44 +00:00
Bruce Momjian 9295eea839 Document ATAPI FLUSH CACHE EXT. 2010-02-27 20:16:17 +00:00
Tom Lane 5667a53b78 Undo some more pgindent breakage. Per buildfarm. 2010-02-27 03:55:52 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane 99419d36f2 Allow predicate_refuted_by() to deduce that NOT A refutes A.
We had originally made the stronger assumption that NOT A refutes any B
if B implies A, but this fails in three-valued logic, because we need to
prove B is false not just that it's not true.  However the logic does
go through if B is equal to A.

Recognizing this limited case is enough to handle examples that arise when
we have simplified "bool_var = true" or "bool_var = false" to just "bool_var"
or "NOT bool_var".  If we had not done that simplification then the
btree-operator proof logic would have been able to prove that the expressions
were contradictory, but only for identical expressions being compared to the
constants; so handling identical A and B covers all the same cases.

The motivation for doing this is to avoid unexpected asymmetrical behavior
when a partitioned table uses a boolean partitioning column, as in today's
gripe from Dominik Sander.

Back-patch to 8.2, which is as far back as predicate_refuted_by attempts to
do anything at all with NOTs.
2010-02-25 20:59:53 +00:00
Bruce Momjian 89ce2bfc13 Add C comment that do_to_timestamp() lacks error checking. 2010-02-25 18:36:14 +00:00
Magnus Hagander 413d34be4e Add configuration parameter ssl_renegotiation_limit to control
how often we do SSL session key renegotiation. Can be set to
0 to disable renegotiation completely, which is required if
a broken SSL library is used (broken patches to CVE-2009-3555
a known cause) or when using a client library that can't do
renegotiation.
2010-02-25 13:26:16 +00:00
Heikki Linnakangas cd2b7d3c4d Fix streaming replication starting at the very first WAL segment.
Per complaint from Greg Stark.
2010-02-25 07:31:40 +00:00
Tom Lane a2239b96e0 Make pg_stop_backup's reporting a bit more verbose in hopes of making
error cases less intimidating for novices.  Per discussion.

Greg Smith
2010-02-25 02:17:50 +00:00
Tom Lane 11b5847058 Add an OR REPLACE option to CREATE LANGUAGE.
This operates in the same way as other CREATE OR REPLACE commands, ie,
it replaces everything but the ownership and ACL lists of an existing
entry, and requires the caller to have owner privileges for that entry.

While modifying an existing language has some use in development scenarios,
in typical usage all the "replaced" values come from pg_pltemplate so there
will be no actual change in the language definition.  The reason for adding
this is mainly to allow programs to ensure that a language exists without
triggering an error if it already does exist.

This commit just adds and documents the new option.  A followon patch
will use it to clean up some unpleasant cases in pg_dump and pg_regress.
2010-02-23 22:51:43 +00:00
Bruce Momjian a54803149a Revert recent change of to_char('HH12') handling for intervals; instead
improve documentation, and add C comment.
2010-02-23 16:14:26 +00:00
Bruce Momjian 4f56dc3fb4 Secondary patch to fix interval to_char() for "HH" where hours >= 12. 2010-02-23 06:29:01 +00:00
Bruce Momjian 7cdadc62ea Supress convertion of zero hours to '12' for intervals when using
to_char with HH, e.g.

	to_char(interval '0d 0h 12m 44s', 'DD HH24 MI SS');

now returns:

	 00 00 12 44

not:

	 00 12 12 44
2010-02-23 01:42:19 +00:00
Tom Lane e9a383303c Adjust pg_fsync_writethrough so that it will set errno when failing
on a platform that doesn't support this operation.  The former coding
would allow an unrelated errno to be reported, which would be quite
misleading.  Not sure if this has anything to do with the current
buildfarm failures, but it's certainly bogus as-is.
2010-02-22 15:26:14 +00:00
Tom Lane 05d8a561ff Clean up handling of XactReadOnly and RecoveryInProgress checks.
Add some checks that seem logically necessary, in particular let's make
real sure that HS slave sessions cannot create temp tables.  (If they did
they would think that temp tables belonging to the master's session with
the same BackendId were theirs.  We *must* not allow myTempNamespace to
become set in a slave session.)

Change setval() and nextval() so that they are only allowed on temp sequences
in a read-only transaction.  This seems consistent with what we allow for
table modifications in read-only transactions.  Since an HS slave can't have a
temp sequence, this also provides a nicer cure for the setval PANIC reported
by Erik Rijkers.

Make the error messages more uniform, and have them mention the specific
command being complained of.  This seems worth the trifling amount of extra
code, since people are likely to see such messages a lot more than before.
2010-02-20 21:24:02 +00:00
Tom Lane 3f56ca1d49 Reduce the rescan cost estimate for Materialize nodes to cpu_operator_cost per
tuple, instead of the former cpu_tuple_cost.  It is sane to charge less than
cpu_tuple_cost because Materialize never does any qual-checking or projection,
so it's got less overhead than most plan node types.  In particular, we want
to have the same charge here as is charged for readout in cost_sort.  That
avoids the problem recently exhibited by Teodor wherein the planner prefers
a useless sort over a materialize step in a context where a lot of rescanning
will happen.  The rescan costs should be just about the same for both node
types, so make their estimates the same.

Not back-patching because all of the current logic for rescan cost estimates
is new in 9.0.  The old handling of rescans is sufficiently not-sane that
changing this in that structure is a bit pointless, and might indeed cause
regressions.
2010-02-19 21:49:10 +00:00
Heikki Linnakangas ad458cfe81 Don't use O_DIRECT when writing WAL files if archiving or streaming is
enabled. Bypassing the kernel cache is counter-productive in that case,
because the archiver/walsender process will read from the WAL file
soon after it's written, and if it's not cached the read will cause
a physical read, eating I/O bandwidth available on the WAL drive.

Also, walreceiver process does unaligned writes, so disable O_DIRECT
in walreceiver process for that reason too.
2010-02-19 10:51:04 +00:00
Heikki Linnakangas 94f610b163 Forbid setval() during recovery. This prevents the PANIC reported by
Erik Rijkers. Patch by Andres Freund.
2010-02-19 06:29:19 +00:00