Robert Haas [Sat, 1 Feb 2014 03:25:01 +0000 (22:25 -0500)]
Merge branch 'master' into slot2
Robert Haas [Sat, 1 Feb 2014 02:31:08 +0000 (21:31 -0500)]
Clear MyProc and MyProcSignalState before they become invalid.
Evidence from buildfarm member crake suggests that the new test_shm_mq
module is routinely crashing the server due to the arrival of a SIGUSR1
after the shared memory segment has been unmapped. Although processes
using the new dynamic background worker facilities are more likely to
receive a SIGUSR1 around this time, the problem is also possible on older
branches, so I'm back-patching the parts of this change that apply to
older branches as far as they apply.
It's already generally the case that code checks whether these pointers
are NULL before deferencing them, so the important thing is mostly to
make sure that they do get set to NULL before they become invalid. But
in master, there's one case in procsignal_sigusr1_handler that lacks a
NULL guard, so add that.
Patch by me; review by Tom Lane.
Bruce Momjian [Sat, 1 Feb 2014 02:28:15 +0000 (21:28 -0500)]
doc: mention statistics reset during crash recovery
Takayuki Tsunakawa
Bruce Momjian [Sat, 1 Feb 2014 01:19:53 +0000 (20:19 -0500)]
chkpass: check for NULL return value from crypt()
Report from Jozef Mlich using Coverity
Bruce Momjian [Sat, 1 Feb 2014 00:04:37 +0000 (19:04 -0500)]
doc: mention data page checksums in WAL section
Backpatch to 9.3
Adjusted patch from Ian Lawrence Barwick
Tom Lane [Fri, 31 Jan 2014 22:51:07 +0000 (17:51 -0500)]
Disallow use of SSL v3 protocol in the server as well as in libpq.
Commit
820f08cabdcbb8998050c3d4873e9619d6d8cba4 claimed to make the server
and libpq handle SSL protocol versions identically, but actually the server
was still accepting SSL v3 protocol while libpq wasn't. Per discussion,
SSL v3 is obsolete, and there's no good reason to continue to accept it.
So make the code really equivalent on both sides. The behavior now is
that we use the highest mutually-supported TLS protocol version.
Marko Kreen, some comment-smithing by me
Bruce Momjian [Fri, 31 Jan 2014 22:44:18 +0000 (17:44 -0500)]
docs: mention tgconstrindid supports exclusion constraints
Dean Rasheed
Tom Lane [Fri, 31 Jan 2014 22:27:50 +0000 (17:27 -0500)]
Add some examples to the postgres_fdw documentation.
Michael Paquier
Bruce Momjian [Fri, 31 Jan 2014 22:08:27 +0000 (17:08 -0500)]
doc: authentication wording improvements
Suggested by David Tonhofer
Bruce Momjian [Fri, 31 Jan 2014 21:37:25 +0000 (16:37 -0500)]
docs: specify FOR UPDATE/SHARE incompatibilities
Document that FOR UPDATE/SHARE are incompatible with GROUP BY, DISTINCT,
HAVING and window functions.
Michael Paquier
Bruce Momjian [Fri, 31 Jan 2014 21:04:18 +0000 (16:04 -0500)]
system catalogs: reorder pg_amproc entries into proper sections
Report form Antonin Houska
Bruce Momjian [Fri, 31 Jan 2014 19:46:00 +0000 (14:46 -0500)]
pgindent: add Perl comment
Bruce Momjian [Fri, 31 Jan 2014 18:35:50 +0000 (13:35 -0500)]
pgindent: add --list-of-typedefs option
Allows typedefs to be specified on the command line, per request from
Andrew.
Fujii Masao [Fri, 31 Jan 2014 16:45:48 +0000 (01:45 +0900)]
Add tab completion for ALTER TABLESPACE MOVE in psql.
Bruce Momjian [Fri, 31 Jan 2014 16:05:15 +0000 (11:05 -0500)]
entab: add new options
Add new entab options to process only C comment whitespace after
periods, and to protect leading whitespace.
Andrew Dunstan [Fri, 31 Jan 2014 14:31:58 +0000 (09:31 -0500)]
Fix documented return type of json_array_elements_text.
Per gripe from hubert depesz lubaczewski.
Also improve examples for this and json_array_elements so they match the
example results.
Robert Haas [Fri, 31 Jan 2014 12:52:24 +0000 (07:52 -0500)]
Merge branch 'master' into slot2
Andres Freund [Fri, 31 Jan 2014 10:44:13 +0000 (11:44 +0100)]
Use consecutive oids for replication slot functions.
Tom Lane [Fri, 31 Jan 2014 07:03:30 +0000 (02:03 -0500)]
Allow unrecognized encoding names in locales, as long as they're the same.
The buildfarm says commit
58274728fb8e087049df67c0eee903d9743fdeda doesn't
work so well on Windows. This is because the encoding part of Windows
locale names can be just a code page number, eg "1252", which we don't
consider to be a valid encoding name. Add a check to accept encoding
parts that are case-insensitively string equal; this at least ensures
that the new code doesn't reject any cases that the old code allowed.
Bruce Momjian [Fri, 31 Jan 2014 03:40:05 +0000 (22:40 -0500)]
pgindent: preserve blank lines around #else/#endif
This requires a new version of pg_bsd_indent, version 1.3, to be
downloaded.
Tom Lane [Fri, 31 Jan 2014 00:07:06 +0000 (19:07 -0500)]
Be forgiving of variant spellings of locale names in pg_upgrade.
Even though the server tries to canonicalize stored locale names, the
platform often doesn't cooperate, so it's entirely possible that one DB
thinks its locale is, say, "en_US.UTF-8" while the other has "en_US.utf8".
Rather than failing, we should try to allow this where it's clearly OK.
There is already pretty robust encoding lookup in encnames.c, so make
use of that to compare the encoding parts of the names. The locale
identifier parts are just compared case-insensitively, which we were
already doing. The major problem known to exist in the field is variant
encoding-name spellings, so hopefully this will be Good Enough. If not,
we can try being even laxer.
Pavel Raiskup, reviewed by Rushabh Lathia
Tom Lane [Thu, 30 Jan 2014 23:10:01 +0000 (18:10 -0500)]
Fix potential coredump on bad locale value in pg_upgrade.
Thinko in error report (and a typo in the message text, too). We're
failing anyway, but it would be good to print something useful first.
Noted while reviewing a patch to make pg_upgrade's locale code laxer.
Robert Haas [Thu, 30 Jan 2014 20:45:14 +0000 (15:45 -0500)]
Add convenience functions pg_sleep_for and pg_sleep_until.
Vik Fearing, reviewed by Pavel Stehule and myself
Tom Lane [Thu, 30 Jan 2014 19:51:16 +0000 (14:51 -0500)]
Fix bogus handling of "postponed" lateral quals.
When pulling a "postponed" qual from a LATERAL subquery up into the quals
of an outer join, we must make sure that the postponed qual is included
in those seen by make_outerjoininfo(). Otherwise we might compute a
too-small min_lefthand or min_righthand for the outer join, leading to
"JOIN qualification cannot refer to other relations" failures from
distribute_qual_to_rels. Subtler errors in the created plan seem possible,
too, if the extra qual would only affect join ordering constraints.
Per bug #9041 from David Leverton. Back-patch to 9.3.
Robert Haas [Thu, 30 Jan 2014 18:38:52 +0000 (13:38 -0500)]
Merge branch 'master' into slot2
Robert Haas [Thu, 30 Jan 2014 18:36:02 +0000 (13:36 -0500)]
Final touches (I hope).
Robert Haas [Thu, 30 Jan 2014 18:28:44 +0000 (13:28 -0500)]
pg prefix-ize.
Robert Haas [Thu, 30 Jan 2014 18:24:46 +0000 (13:24 -0500)]
Teach CreateSlotOnDisk to try to clean up after previous failures.
Robert Haas [Thu, 30 Jan 2014 17:31:25 +0000 (12:31 -0500)]
Merge branch 'master' into slot2
Bruce Momjian [Thu, 30 Jan 2014 17:26:18 +0000 (12:26 -0500)]
docs: improve xref description for xreflabel and refentry links
Bruce Momjian [Thu, 30 Jan 2014 17:21:48 +0000 (12:21 -0500)]
docs: mention SGML refentry also pulls text from the link
Bruce Momjian [Thu, 30 Jan 2014 17:14:24 +0000 (12:14 -0500)]
docs: add mention of index swapping
Backpatch to 9.3
Greg Smith
Bruce Momjian [Thu, 30 Jan 2014 14:41:43 +0000 (09:41 -0500)]
Add checks for interval overflow/underflow
New checks include input, month/day/time internal adjustments, addition,
subtraction, multiplication, and negation. Also adjust docs to
correctly specify interval size in bytes.
Report from Rok Kralj
Andres Freund [Thu, 30 Jan 2014 07:09:41 +0000 (08:09 +0100)]
slot: docs: adjust example to the fact that we now return NULLs in pg_replication_slots
Robert Haas [Thu, 30 Jan 2014 03:25:42 +0000 (22:25 -0500)]
Rename data_xmin->xmin.
Robert Haas [Thu, 30 Jan 2014 01:27:37 +0000 (20:27 -0500)]
Document hazards of --slot.
Robert Haas [Thu, 30 Jan 2014 01:17:17 +0000 (20:17 -0500)]
Copy-edit comment.
Tom Lane [Thu, 30 Jan 2014 01:03:57 +0000 (20:03 -0500)]
Fix unsafe references to errno within error messaging logic.
Various places were supposing that errno could be expected to hold still
within an ereport() nest or similar contexts. This isn't true necessarily,
though in some cases it accidentally failed to fail depending on how the
compiler chanced to order the subexpressions. This class of thinko
explains recent reports of odd failures on clang-built versions, typically
missing or inappropriate HINT fields in messages.
Problem identified by Christian Kruse, who also submitted the patch this
commit is based on. (I fixed a few issues in his patch and found a couple
of additional places with the same disease.)
Back-patch as appropriate to all supported branches.
Andrew Dunstan [Wed, 29 Jan 2014 23:54:14 +0000 (18:54 -0500)]
Silence compiler warnings about possibly unset variables.
They are in fact set in every case where they are needed, but the
compiler doesn't know that.
Per gripe from Tom Lane.
Andres Freund [Wed, 29 Jan 2014 23:30:07 +0000 (00:30 +0100)]
slot: Only send the flush position in receivelog.c when a slot is being used
Robert Haas [Wed, 29 Jan 2014 22:57:15 +0000 (17:57 -0500)]
Doc edits.
Robert Haas [Wed, 29 Jan 2014 22:07:48 +0000 (17:07 -0500)]
Merge branch 'master' into slot2
Andrew Dunstan [Wed, 29 Jan 2014 21:38:31 +0000 (16:38 -0500)]
Forgot to bump catalog version for json_array_elements_text.
Robert Haas [Wed, 29 Jan 2014 21:04:19 +0000 (16:04 -0500)]
Include planning time in EXPLAIN ANALYZE output.
This doesn't work for prepared queries, but it's not too easy to get
the information in that case and there's some debate as to exactly
what the right thing to measure is, so just do this for now.
Andreas Karlsson, with slight doc changes by me.
Andrew Dunstan [Wed, 29 Jan 2014 20:39:01 +0000 (15:39 -0500)]
Add json_array_elements_text function.
This was a notable omission from the json functions added in 9.3 and
there have been numerous complaints about its absence.
Laurence Rowe.
Heikki Linnakangas [Wed, 29 Jan 2014 19:33:56 +0000 (21:33 +0200)]
Fix thinko in huge_tlb_pages patch.
We calculated the rounded-up size for the allocation, but then failed to
use the rounded-up value in the mmap() call. Oops.
Also, initialize allocsize, to silence warnings seen with some compilers,
as pointed out by Jeff Janes.
Heikki Linnakangas [Wed, 29 Jan 2014 19:22:08 +0000 (21:22 +0200)]
Further optimize GIN multi-key searches.
When skipping over some items in a posting tree, re-find the new location
by descending the tree from root, rather than walking the right links.
This can save a lot of I/O.
Heavily modified from Alexander Korotkov's fast scan patch.
Bruce Momjian [Wed, 29 Jan 2014 18:31:11 +0000 (13:31 -0500)]
Fix pointer processing in new entab.c function
Bruce Momjian [Wed, 29 Jan 2014 17:48:07 +0000 (12:48 -0500)]
Add C functions to centralize entab processing
Bruce Momjian [Wed, 29 Jan 2014 17:22:12 +0000 (12:22 -0500)]
Add more C comments to entab.c.
Andres Freund [Wed, 29 Jan 2014 17:01:09 +0000 (18:01 +0100)]
slot: also recompute pegged lsn on drop
Heikki Linnakangas [Wed, 29 Jan 2014 16:23:17 +0000 (18:23 +0200)]
Further optimize multi-key GIN searches.
If we're skipping past a certain TID, avoid decoding posting list segments
that only contain smaller TIDs.
Extracted from Alexander Korotkov's fast scan patch, heavily modified.
Andres Freund [Wed, 29 Jan 2014 16:04:12 +0000 (17:04 +0100)]
Return nulls instead of InvalidTransactionId/InvalidXLogRecPtr in pg_replication_slots
Robert Haas [Wed, 29 Jan 2014 15:57:38 +0000 (10:57 -0500)]
Merge branch 'master' into slot2
Heikki Linnakangas [Wed, 29 Jan 2014 15:53:39 +0000 (17:53 +0200)]
Allow skipping some items in a multi-key GIN search.
In a multi-key search, ie. something like "col @> 'foo' AND col @> 'bar'",
as soon as we find the next item that matches the first criteria, we don't
need to check the second criteria for TIDs smaller the first match. That
saves a lot of effort, especially if one of the terms is rare, while the
second occurs very frequently.
Based on ideas from Alexander Korotkov's fast scan patch.
Andres Freund [Wed, 29 Jan 2014 15:29:29 +0000 (16:29 +0100)]
? Don't copy pg_replslot in basebackups.
Andres Freund [Wed, 29 Jan 2014 15:28:57 +0000 (16:28 +0100)]
Initial cut at replication slot docs.
Andres Freund [Wed, 29 Jan 2014 15:13:41 +0000 (16:13 +0100)]
pg_receivexlog: slot documentation update
Andrew Dunstan [Wed, 29 Jan 2014 14:51:02 +0000 (09:51 -0500)]
Remedy two small omissions in the new json functions docs.
Heikki Linnakangas [Wed, 29 Jan 2014 14:16:19 +0000 (16:16 +0200)]
Fix docs build.
Broken by the huge_tlb_pages patch.
Vik Fearing.
Andres Freund [Wed, 29 Jan 2014 12:57:17 +0000 (13:57 +0100)]
Trailing whitespace
Andres Freund [Wed, 29 Jan 2014 12:56:55 +0000 (13:56 +0100)]
More robust KeepLogSeg() coding
Andres Freund [Wed, 29 Jan 2014 12:54:54 +0000 (13:54 +0100)]
pg_receivexlog: slot support
Heikki Linnakangas [Wed, 29 Jan 2014 11:44:45 +0000 (13:44 +0200)]
Allow using huge TLB pages on Linux (MAP_HUGETLB)
This patch adds an option, huge_tlb_pages, which allows requesting the
shared memory segment to be allocated using huge pages, by using the
MAP_HUGETLB flag in mmap(). This can improve performance.
The default is 'try', which means that we will attempt using huge pages,
and fall back to non-huge pages if it doesn't work. Currently, only Linux
has MAP_HUGETLB. On other platforms, the default 'try' behaves the same as
'off'.
In the passing, don't try to round the mmap() size to a multiple of
pagesize. mmap() doesn't require that, and there's no particular reason for
PostgreSQL to do that either. When using MAP_HUGETLB, however, round the
request size up to nearest 2MB boundary. This is to work around a bug in
some Linux kernel versions, but also to avoid wasting memory, because the
kernel will round the size up anyway.
Many people were involved in writing this patch, including Christian Kruse,
Richard Poole, Abhijit Menon-Sen, reviewed by Peter Geoghegan, Andres Freund
and me.
Robert Haas [Wed, 29 Jan 2014 04:35:50 +0000 (23:35 -0500)]
Fix compiler warning in EXEC_BACKEND builds.
Per a report by Rajeev Rastogi.
Andrew Dunstan [Tue, 28 Jan 2014 23:28:16 +0000 (18:28 -0500)]
Minor docs fixes for new json functions.
Thom Brown.
Andrew Dunstan [Tue, 28 Jan 2014 23:10:00 +0000 (18:10 -0500)]
Add new make targets check-tests and installcheck-tests.
These do not run any specific schedule of tests, but only those
specified as part of the invocation, e.g.:
make check-tests TESTS="json jsonb"
Andrew Dunstan [Tue, 28 Jan 2014 22:48:21 +0000 (17:48 -0500)]
New json functions.
json_build_array() and json_build_object allow for the construction of
arbitrarily complex json trees. json_object() turns a one or two
dimensional array, or two separate arrays, into a json_object of
name/value pairs, similarly to the hstore() function.
json_object_agg() aggregates its two arguments into a single json object
as name value pairs.
Catalog version bumped.
Andrew Dunstan, reviewed by Marko Tiikkaja.
Andres Freund [Tue, 28 Jan 2014 22:27:37 +0000 (23:27 +0100)]
update copyright years
Andres Freund [Tue, 28 Jan 2014 21:48:36 +0000 (22:48 +0100)]
Don't ERROR, just LOG problems during replication slot checkpoints
Andres Freund [Tue, 28 Jan 2014 20:51:38 +0000 (21:51 +0100)]
Support tracking the dirty state of replication slots.
Robert Haas [Tue, 28 Jan 2014 20:58:41 +0000 (15:58 -0500)]
Assorted tidying up.
Robert Haas [Tue, 28 Jan 2014 20:46:27 +0000 (15:46 -0500)]
Minor tweaks.
Robert Haas [Tue, 28 Jan 2014 20:27:52 +0000 (15:27 -0500)]
Merge remote-tracking branch 'afreund/slot2' into slot2
Conflicts:
src/backend/replication/slotfuncs.c
src/include/replication/slot.h
Robert Haas [Tue, 28 Jan 2014 20:23:09 +0000 (15:23 -0500)]
Zap unnecessary logical-decoding reference.
Andres Freund [Tue, 28 Jan 2014 20:15:34 +0000 (21:15 +0100)]
minor cleanups
Andres Freund [Tue, 28 Jan 2014 19:52:23 +0000 (20:52 +0100)]
replication slot checkpointing
Robert Haas [Tue, 28 Jan 2014 20:14:56 +0000 (15:14 -0500)]
Update make check expected output.
Robert Haas [Tue, 28 Jan 2014 20:14:11 +0000 (15:14 -0500)]
Commment updates.
Robert Haas [Tue, 28 Jan 2014 19:55:54 +0000 (14:55 -0500)]
Tidy up comments, includes.
Andres Freund [Tue, 28 Jan 2014 19:16:27 +0000 (20:16 +0100)]
slot: Separate data stored on-disk from purely in-memory state
Robert Haas [Tue, 28 Jan 2014 19:07:31 +0000 (14:07 -0500)]
New recovery.conf parameter, primary_slotname.
So you can, like, use slots.
Andres Freund [Tue, 28 Jan 2014 18:48:26 +0000 (19:48 +0100)]
Re-Add hunk initalizing replication slots in StartupXLOG(), slipped to a later patch.
Andres Freund [Tue, 28 Jan 2014 17:51:33 +0000 (18:51 +0100)]
Don't let ReplicationSlotAcquire succeed in the midst of ReplicationSlotCreate.
Robert Haas [Tue, 28 Jan 2014 18:34:31 +0000 (13:34 -0500)]
Fix field count.
Robert Haas [Tue, 28 Jan 2014 18:33:51 +0000 (13:33 -0500)]
Don't exit the loop with slot set unless we really found a slot.
Fujii Masao [Tue, 28 Jan 2014 17:58:22 +0000 (02:58 +0900)]
Add pg_stat_archiver statistics view.
This view shows the statistics about the WAL archiver process's activity.
Gabriele Bartolini, reviewed by Michael Paquier, refactored a bit by me.
Tom Lane [Tue, 28 Jan 2014 17:34:29 +0000 (12:34 -0500)]
Update comment.
generate_normalized_query() no longer needs to truncate text, but this
one comment didn't get the memo. Per Peter Geoghegan.
Bruce Momjian [Tue, 28 Jan 2014 17:28:14 +0000 (12:28 -0500)]
Revert C comment change in slot_attisnull()
Revert
89774b58b0ea2874765cae10c094bb6aaf707feb
Bruce Momjian [Tue, 28 Jan 2014 16:29:39 +0000 (11:29 -0500)]
Remove orphaned prototype
Rajeev rastogi
Robert Haas [Tue, 28 Jan 2014 16:21:56 +0000 (11:21 -0500)]
remove confirmed_flush and other crud
Robert Haas [Tue, 28 Jan 2014 16:16:18 +0000 (11:16 -0500)]
Minor edits.
Robert Haas [Tue, 28 Jan 2014 15:43:05 +0000 (10:43 -0500)]
Remove hunk.
Robert Haas [Tue, 28 Jan 2014 15:40:02 +0000 (10:40 -0500)]
Renaming, other consolidation.
Robert Haas [Tue, 28 Jan 2014 15:26:13 +0000 (10:26 -0500)]
Rename stuff.
Stephen Frost [Tue, 28 Jan 2014 13:40:41 +0000 (08:40 -0500)]
Revert dup2() checking in syslogger.c
Per the expanded comment-
As we're just trying to reset these to go to DEVNULL, there's not
much point in checking for failure from the close/dup2 calls here,
if they fail then presumably the file descriptors are closed and
any writes will go into the bitbucket anyway.
Pointed out by Tom.
Tom Lane [Tue, 28 Jan 2014 02:04:09 +0000 (21:04 -0500)]
Log a detail message for auth failures due to missing or expired password.
It's worth distinguishing these cases from run-of-the-mill wrong-password
problems, since users have been known to waste lots of time pursuing the
wrong theory about what's failing. Now, our longstanding policy about how
to report authentication failures is that we don't really want to tell the
*client* such things, since that might be giving information to a bad guy.
But there's nothing wrong with reporting the details to the postmaster log,
and indeed the comments in this area of the code contemplate that
interesting details should be so reported. We just weren't handling these
particular interesting cases usefully.
To fix, add infrastructure allowing subroutines of ClientAuthentication()
to return a string to be added to the errdetail_log field of the main
authentication-failed error report. We might later want to use this to
report other subcases of authentication failure the same way, but for the
moment I just dealt with password cases.
Per discussion of a patch from Josh Drake, though this is not what
he proposed.
Robert Haas [Mon, 27 Jan 2014 23:29:38 +0000 (18:29 -0500)]
Move LWLockReleaseAll in WalSndErrorCleanup sooner.
Robert Haas [Mon, 27 Jan 2014 22:53:33 +0000 (17:53 -0500)]
Fix inadvertent rebasing mistake.
Robert Haas [Mon, 27 Jan 2014 22:51:32 +0000 (17:51 -0500)]
fix trailing whitespace