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
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
doc: mention data page checksums in WAL section

Backpatch to 9.3

Adjusted patch from Ian Lawrence Barwick
chkpass:  check for NULL return value from crypt()

Report from Jozef Mlich using Coverity
doc: mention statistics reset during crash recovery

Takayuki Tsunakawa
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.
pg_restore:  make help output plural for multi-enabled options

per report from Josh Kupershmidt