Commit Graph

11151 Commits

Author SHA1 Message Date
Tom Lane 3ceb44fa0a Adjust misleading comment in walsender.c. We try to send all WAL data that's
been written out from shared memory, but the previous phrasing might be read
to say that we send only what's been fsync'd.
2010-06-03 23:00:14 +00:00
Tom Lane 0cc59cc1f3 Add current WAL end (as seen by walsender, ie, GetWriteRecPtr() result)
and current server clock time to SR data messages.  These are not currently
used on the slave side but seem likely to be useful in future, and it'd be
better not to change the SR protocol after release.  Per discussion.
Also do some minor code review and cleanup on walsender.c, and improve the
protocol documentation.
2010-06-03 22:17:32 +00:00
Peter Eisentraut 1eca1b7a68 Translation updates for 9.0beta2 2010-06-03 21:12:05 +00:00
Peter Eisentraut cb6038c168 Fix some inconsistent quoting of wal_level values in messages
When referring to postgresql.conf syntax, then it's without quotes
(wal_level=archive); in narrative it's with double quotes.  But never
single quotes.
2010-06-03 21:02:12 +00:00
Peter Eisentraut af3c7e60ee Fix reference to nonexistent configure option
--enable-ssl -> --with-openssl
2010-06-03 19:29:38 +00:00
Robert Haas d561430b66 On clean shutdown during recovery, don't warn about possible corruption.
Fujii Masao.  Review by Heikki Linnakangas and myself.
2010-06-03 03:20:00 +00:00
Heikki Linnakangas 6b24036365 Fix obsolete comments that I neglected to update in a previous patch.
Fujii Masao
2010-06-02 09:28:44 +00:00
Bruce Momjian 309193bbd3 Show schema name for REINDEX.
Greg Sabino Mullane
2010-06-01 00:33:23 +00:00
Heikki Linnakangas e0b581acd2 Send all outstanding WAL before exiting when smart shutdown is requested.
This was broken by my previous patch to send WAL in smaller batches.

Patch by Fujii Masao.
2010-05-31 10:44:37 +00:00
Tom Lane bc0f080928 Fix misuse of Lossy Counting (LC) algorithm in compute_tsvector_stats().
We must filter out hashtable entries with frequencies less than those
specified by the algorithm, else we risk emitting junk entries whose
actual frequency is much less than other lexemes that did not get
tabulated.  This is bad enough by itself, but even worse is that
tsquerysel() believes that the minimum frequency seen in pg_statistic is a
hard upper bound for lexemes not included, and was thus underestimating
the frequency of non-MCEs.

Also, set the threshold frequency to something with a little bit of theory
behind it, to wit assume that the input distribution is approximately
Zipfian.  This might need adjustment in future, but some preliminary
experiments suggest that it's not too unreasonable.

Back-patch to 8.4, where this code was introduced.

Jan Urbanski, with some editorialization by Tom
2010-05-30 21:59:02 +00:00
Tom Lane b12b7a9038 Change the notation for calling functions with named parameters from
"val AS name" to "name := val", as per recent discussion.

This patch catches everything in the original named-parameters patch,
but I'm not certain that no other dependencies snuck in later (grepping
the source tree for all uses of AS soon proved unworkable).

In passing I note that we've dropped the ball at least once on keeping
ecpg's lexer (as opposed to parser) in sync with the backend.  It would
be a good idea to go through all of pgc.l and see if it's in sync now.
I didn't attempt that at the moment.
2010-05-30 18:10:41 +00:00
Bruce Momjian 7190220555 Add C comment that we will have to remove an exclusion constraint check
if we ever implement '<>' index opclasses.

Jeff Davis
2010-05-29 02:32:08 +00:00
Tom Lane ece869b11e Fix oversight in the previous patch that made LIKE throw error for \ at the
end of the pattern: the code path that handles \ just after % should throw
error too.  As in the previous patch, not back-patching for fear of breaking
apps that worked before.
2010-05-28 18:18:19 +00:00
Tom Lane dbde97cdde Rewrite LIKE's %-followed-by-_ optimization so it really works (this time
for sure ;-)).  It now also optimizes more cases, such as %_%_.  Improve
comments too.  Per bug #5478.

In passing, also rename the TCHAR macro to GETCHAR, because pgindent is
messing with the formatting of the former (apparently it now thinks TCHAR
is a typedef name).

Back-patch to 8.3, where the bug was introduced.
2010-05-28 17:35:23 +00:00
Tom Lane f39d57b83c Rejigger mergejoin logic so that a tuple with a null in the first merge column
is treated like end-of-input, if nulls sort last in that column and we are not
doing outer-join filling for that input.  In such a case, the tuple cannot
join to anything from the other input (because we assume mergejoinable
operators are strict), and neither can any tuple following it in the sort
order.  If we're not interested in doing outer-join filling we can just
pretend the tuple and its successors aren't there at all.  This can save a
great deal of time in situations where there are many nulls in the join
column, as in a recent example from Scott Marlowe.  Also, since the planner
tends to not count nulls in its mergejoin scan selectivity estimates, this
is an important fix to make the runtime behavior more like the estimate.

I regard this as an omission in the patch I wrote years ago to teach mergejoin
that tuples containing nulls aren't joinable, so I'm back-patching it.  But
only to 8.3 --- in older versions, we didn't have a solid notion of whether
nulls sort high or low, so attempting to apply this optimization could break
things.
2010-05-28 01:14:03 +00:00
Tom Lane ede5072676 Change ps_status.c to explicitly track the current logical length of ps_buffer.
This saves cycles in get_ps_display() on many popular platforms, and more
importantly ensures that get_ps_display() will correctly return an empty
string if init_ps_display() hasn't been called yet.  Per trouble report
from Ray Stell, in which log_line_prefix %i produced junk early in backend
startup.

Back-patch to 8.0.  7.4 doesn't have %i and its version of get_ps_display()
makes no pretense of avoiding pad junk anyhow.
2010-05-27 19:19:38 +00:00
Tom Lane 5a86e5e193 Make CREATE INDEX run expression preprocessing on a proposed index expression
before it checks whether the expression is immutable.  This covers two cases
that were previously handled poorly:

1. SQL function inlining could reduce the apparent volatility of the
expression, allowing an expression to be accepted where it previously would
not have been.  As an example, polymorphic functions must be marked with the
worst-case volatility they have for any argument type, but for specific
argument types they might not be so volatile, so indexing could be allowed.
(Since the planner will refuse to inline functions in cases where the
apparent volatility of the expression would increase, this won't break
any cases that were accepted before.)

2. A nominally immutable function could have default arguments that are
volatile expressions.  In such a case insertion of the defaults will increase
both the apparent and actual volatility of the expression, so it is
*necessary* to check this before allowing the expression to be indexed.

Back-patch to 8.4, where default arguments were introduced.
2010-05-27 15:59:10 +00:00
Robert Haas 5e85315ea7 Avoid starting walreceiver in states where it shouldn't be running.
In particular, it's bad to start walreceiver when in state
PM_WAIT_BACKENDS, because we have no provision to kill walreceiver
when in that state.

Fujii Masao
2010-05-27 02:01:37 +00:00
Heikki Linnakangas c5bd8feac6 Adjust comment to reflect that we now have Hot Standby. Pointed out by
Robert Haas.
2010-05-27 00:38:39 +00:00
Heikki Linnakangas fbcdff39bd Thinko in previous commit: ensure that MAX_SEND_SIZE is always greater
than XLOG_BLCKSZ, by defining it as 16 * XLOG_BLCKSZ rather than directly
as 128k bytes.
2010-05-26 22:34:49 +00:00
Heikki Linnakangas ea5516081d In walsender, don't sleep if there's outstanding WAL waiting to be sent,
otherwise we effectively rate-limit the streaming as pointed out by
Simon Riggs. Also, send the WAL in smaller chunks, to respond to signals
more promptly.
2010-05-26 22:21:33 +00:00
Tom Lane 0d046a4d72 Fix bogus error message for SSL-cert authentication, due to lack of
a uaCert entry in auth_failed().  Put the switch entries into a sane
order, namely the one the enum is declared in.
2010-05-26 20:47:13 +00:00
Simon Riggs f9dbac9476 HS Defer buffer pin deadlock check until deadlock_timeout has expired.
During Hot Standby we need to check for buffer pin deadlocks when the
Startup process begins to wait, in case it never wakes up again. We
previously made the deadlock check immediately on the basis it was
cheap, though clearer thinking and prima facie evidence shows that
was too simple. Refactor existing code to make it easy to add in
deferral of deadlock check until deadlock_timeout allowing a good
reduction in deadlock checks since far few buffer pins are held for
that duration. It's worth doing anyway, though major goal is to
prevent further reports of context switching with high numbers of
users on occasional tests.
2010-05-26 19:52:52 +00:00
Tom Lane af5be8bd40 The message style police pay a visit to hba.c. 2010-05-26 16:43:13 +00:00
Tom Lane b1993a6108 Minor editorialization for be-secure.c: fix comments and some formatting
infelicities.
2010-05-26 16:15:57 +00:00
Tom Lane c3bf3bf2aa Tell openssl to include the names of the root certs the server trusts in
requests for client certs.  This lets a client with a keystore select the
appropriate client certificate to send.  In particular, this is necessary
to get Java clients to work in all but the most trivial configurations.
Per discussion of bug #5468.

Craig Ringer
2010-05-26 15:52:37 +00:00
Robert Haas 615704af1e More fixes for shutdown during recovery.
1. If we receive a fast shutdown request while in the PM_STARTUP state,
process it just as we would in PM_RECOVERY, PM_HOT_STANDBY, or PM_RUN.
Without this change, an early fast shutdown followed by Hot Standby causes
the database to get stuck in a state where a shutdown is pending (so no new
connections are allowed) but the shutdown request is never processed unless
we end Hot Standby and enter normal running.

2. Avoid removing the backup label file when a smart or fast shutdown occurs
during recovery.  It makes sense to do this once we've reached normal running,
since we must be taking a backup which now won't be valid.  But during
recovery we must be recovering from a previously taken backup, and any backup
label file is needed to restart recovery from the right place.

Fujii Masao and Robert Haas
2010-05-26 12:32:41 +00:00
Tom Lane b486e7f382 Fix oversight in construction of sort/unique plans for UniquePaths.
If the original IN operator is cross-type, for example int8 = int4,
we need to use int4 < int4 to sort the inner data and int4 = int4
to unique-ify it.  We got the first part of that right, but tried to
use the original IN operator for the equality checks.  Per bug #5472
from Vlad Romascanu.

Backpatch to 8.4, where the bug was introduced by the patch that unified
SortClause and GroupClause.  I was able to take out a whole lot of on-the-fly
calls of get_equality_op_for_ordering_op(), but failed to realize that
I needed to put one back in right here :-(
2010-05-25 17:44:41 +00:00
Tom Lane 7df4cf7fd3 Fix oversight in join removal patch: we have to delete the removed relation
from SpecialJoinInfo relid sets as well.  Per example from Vaclav Novotny.
2010-05-23 16:34:38 +00:00
Robert Haas ea9968c331 Rename PM_RECOVERY_CONSISTENT and PMSIGNAL_RECOVERY_CONSISTENT.
The new names PM_HOT_STANDBY and PMSIGNAL_BEGIN_HOT_STANDBY more accurately
reflect their actual function.
2010-05-15 20:01:32 +00:00
Simon Riggs 4a24c9a063 Fix bug in processing of checkpoint time for max_standby_delay. Latest
log time was incorrectly set, typically leading to dates in the past,
which would cause more cancellations in Hot Standby on a quiet server.
2010-05-15 07:14:43 +00:00
Robert Haas a724584735 We now accept read-only connections in state PM_RECOVERY_CONSISTENT. 2010-05-14 18:08:33 +00:00
Itagaki Takahiro 0b38f3b192 Remove CRs. 2010-05-14 10:37:02 +00:00
Simon Riggs fd34374b17 Add many new Asserts in code and fix simple bug that slipped through
without them, related to previous commit. Report by Bruce Momjian.
2010-05-14 07:11:49 +00:00
Peter Eisentraut f1ac08daee Translation update 2010-05-13 15:56:43 +00:00
Peter Eisentraut 3393551d54 Fix vpath installation from distribution tarball (bug #5447) 2010-05-13 11:49:48 +00:00
Simon Riggs 463f151a23 Ensure that top level aborts call XLogSetAsyncCommit(). Not doing
so simply leads to data waiting in wal_buffers which then causes
later commits to potentially do emergency writes and for all forms
of replication to be potentially delayed without need or benefit.
Issue pointed out exactly by Fujii Masao, following bug report
by Robert Haas on a separate though related topic.
2010-05-13 11:39:30 +00:00
Simon Riggs 8431e296ea Cleanup initialization of Hot Standby. Clarify working with reanalysis
of requirements and documentation on LogStandbySnapshot(). Fixes
two minor bugs reported by Tom Lane that would lead to an incorrect
snapshot after transaction wraparound. Also fix two other problems
discovered that would give incorrect snapshots in certain cases.
ProcArrayApplyRecoveryInfo() substantially rewritten. Some minor
refactoring of xact_redo_apply() and ExpireTreeKnownAssignedTransactionIds().
2010-05-13 11:15:38 +00:00
Bruce Momjian c7c012ce56 Update comment about why postmaster doesn't get an icon. 2010-05-12 23:48:36 +00:00
Bruce Momjian 0c6b9308de Remove Makefile PGFILEDESC tag that the postmaster is an executable. 2010-05-12 21:42:21 +00:00
Simon Riggs 66035734ec Give most recovery conflict errors a retryable error code. From recent
requests and discussions with Yeb Havinga and Kevin Grittner.
2010-05-12 19:45:02 +00:00
Bruce Momjian 395d1259ad Add PGFILEDESC description to Makefiles for all /contrib executables.
Add PGAPPICON to all executable makefiles.
2010-05-12 11:33:10 +00:00
Tom Lane 4a69624f49 Cause the archiver process to adopt new postgresql.conf settings (particularly
archive_command) as soon as possible, namely just before issuing a new call
of archive_command, even when there is a backlog of files to be archived.
The original coding would only absorb new settings after clearing the backlog
and returning to the outer loop.  Per discussion.

Back-patch to 8.3.  The logic in prior versions is a bit different and it
doesn't seem worth taking any risks of breaking it.
2010-05-11 16:42:28 +00:00
Tom Lane b7987f8a94 Fix incorrect patch that removed permission checks on inheritance child
tables --- the parent table no longer got checked, either.  Per bug #5458
from Takahiro Itagaki.
2010-05-11 15:31:37 +00:00
Itagaki Takahiro 5d6d037822 Set per-function GUC settings during validating the function.
Now validators work properly even when the settings contain
parameters that affect behavior of the function, like search_path.

Reported by Erwin Brandstetter.
2010-05-11 04:52:28 +00:00
Tom Lane ed83f6e382 When adding a "target IS NOT NULL" indexqual to the plan for an index-optimized
MIN or MAX, we must take care to insert the added qual in a legal place among
the existing indexquals, if any.  The btree index AM requires the quals to
appear in index-column order.  We didn't have to worry about this before
because "target IS NOT NULL" was just treated as a plain scan filter condition;
but as of 9.0 it can be an index qual and then it has to follow the rule.
Per report from Ian Barwick.
2010-05-10 16:25:46 +00:00
Tom Lane 2ea56cbda6 Fix missing static declaration for XLogRead(). 2010-05-09 18:11:55 +00:00
Tom Lane ed437e2b27 Adjust comments about avoiding use of printf's %.*s.
My initial impression that glibc was measuring the precision in characters
(which is what the Linux man page says it does) was incorrect.  It does take
the precision to be in bytes, but it also tries to truncate the string at a
character boundary.  The bottom line remains the same: it will mess up
if the string is not in the encoding it expects, so we need to avoid %.*s
anytime there's a significant risk of that.  Previous code changes are still
good, but adjust the comments to reflect this knowledge.  Per research by
Hernan Gonzalez.
2010-05-09 02:16:00 +00:00
Tom Lane 54cd4f0457 Work around a subtle portability problem in use of printf %s format.
Depending on which spec you read, field widths and precisions in %s may be
counted either in bytes or characters.  Our code was assuming bytes, which
is wrong at least for glibc's implementation, and in any case libc might
have a different idea of the prevailing encoding than we do.  Hence, for
portable results we must avoid using anything more complex than just "%s"
unless the string to be printed is known to be all-ASCII.

This patch fixes the cases I could find, including the psql formatting
failure reported by Hernan Gonzalez.  In HEAD only, I also added comments
to some places where it appears safe to continue using "%.*s".
2010-05-08 16:39:53 +00:00
Heikki Linnakangas ffe8c7c677 Need to hold ControlFileLock while updating control file. Update
minRecoveryPoint in control file when replaying a parameter change record,
to ensure that we don't allow hot standby on WAL generated without
wal_level='hot_standby' after a standby restart.
2010-05-03 11:17:52 +00:00