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
docs:  add mention of index swapping

Backpatch to 9.3

Greg Smith
docs:  mention SGML refentry also pulls text from the link
docs:  improve xref description for xreflabel and refentry links
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.
Add convenience functions pg_sleep_for and pg_sleep_until.

Vik Fearing, reviewed by Pavel Stehule and myself
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.
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
pgindent:  preserve blank lines around #else/#endif

This requires a new version of pg_bsd_indent, version 1.3, to be
downloaded.
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.
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.
entab:  add new options

Add new entab options to process only C comment whitespace after
periods, and to protect leading whitespace.
Add tab completion for ALTER TABLESPACE MOVE in psql.
pgindent:  add --list-of-typedefs option

Allows typedefs to be specified on the command line, per request from
Andrew.
pgindent:  add Perl comment
system catalogs:  reorder pg_amproc entries into proper sections

Report form Antonin Houska
docs:  specify FOR UPDATE/SHARE incompatibilities

Document that FOR UPDATE/SHARE are incompatible with GROUP BY, DISTINCT,
HAVING and window functions.

Michael Paquier
doc: authentication wording improvements

Suggested by David Tonhofer
Add some examples to the postgres_fdw documentation.

Michael Paquier
docs:  mention tgconstrindid supports exclusion constraints

Dean Rasheed