Tidy up the populate/to_record{set} code for json a bit.

In the process fix a small bug.
Fix 'recheck' flag in tsquery's GIN tri-consistent function.

It needs to be initialized, like in the boolean gin_tsquery_consistent
version.

Peter Geoghegan.
Add -f/--follow option to pg_xlogdump.

This is useful for seeing what WAL records are inserted in real-time, by
pointing pg_xlogdump to a live server.
Use pg_usleep() instead of plain sleep(), to fix Windows build

Per buildfarm.
Cleanup around json_to_record/json_to_recordset

Set function parameter names and defaults. Add jsonb versions (which the
code already provided for so the actual new code is trivial). Add jsonb
regression tests and docs.

Bump catalog version (which I apparently forgot to do when jsonb was
committed).
pg_upgrade: use pg_usleep();  remove Windows workaround
psql:  update "replica identity" display for \d+

Display "replica identity" only for \d plus mode, exclude system schema
objects, and display all possible values, not just non-default,
non-index ones.
Pass more than the first XLogRecData entry to rm_desc, with WAL_DEBUG.

If you compile with WAL_DEBUG and enable it with wal_debug=on, we used to
only pass the first XLogRecData entry to the rm_desc routine. I think the
original assumprion was that the first XLogRecData entry contains all the
necessary information for the rm_desc routine, but that's a pretty shaky
assumption. At least standby_redo didn't get the memo.

To fix, piece together all the data in a temporary buffer, and pass that to
the rm_desc routine.

It's been like this forever, but the patch didn't apply cleanly to
back-branches. Probably wouldn't be hard to fix the conflicts, but it's
not worth the trouble.
Fix refcounting bug in PLy_modify_tuple().

We must increment the refcount on "plntup" as soon as we have the
reference, not sometime later.  Otherwise, if an error is thrown in
between, the Py_XDECREF(plntup) call in the PG_CATCH block removes a
refcount we didn't add, allowing the object to be freed even though
it's still part of the plpython function's parsetree.

This appears to be the cause of crashes seen on buildfarm member
prairiedog.  It's a bit surprising that we've not seen it fail repeatably
before, considering that the regression tests have been exercising the
faulty code path since 2009.

The real-world impact is probably minimal, since it's unlikely anyone would
be provoking the "TD["new"] is not a dictionary" error in production, and
that's the only case that is actually wrong.  Still, it's a bug affecting
the regression tests, so patch all supported branches.

In passing, remove dead variable "plstr", and demote "platt" to a local
variable inside the PG_TRY block, since we don't need to clean it up
in the PG_CATCH path.
Fix uninitialized variables in json's populate_record_worker().

Peter Geoghegan.
Document that Python 2.3 requires cdecimal module for full functionality.

This has been true for some time, but we were leaving users to discover it
the hard way.

Back-patch to 9.2.  It might've been true before that, but we were claiming
Python 2.2 compatibility before that, so I won't guess at the exact
requirements back then.
Silence compiler warnings in new jsonb code.

Amit Kapila.
contrib/test_decoding:  adjust expected output

Expected output has changed because of psql replica identity output
changes.

Reported by Christoph Berg
Improve documentation note about Python 2.3 and cdecimal.

Explain exactly what fails (ie, function arguments of type numeric)
if you don't have it.
Un-break peer authentication.

Commit 613c6d26bd42dd8c2dd0664315be9551475b8864 sloppily replaced a
lookup of the UID obtained from getpeereid() with a lookup of the
server's own user name, thus totally destroying peer authentication.
Revert.  Per report from Christoph Berg.

In passing, make sure get_user_name() zeroes *errstr on success on
Windows as well as non-Windows.  I don't think any callers actually
depend on this ATM, but we should be consistent across platforms.
Fix EquivalenceClass processing for nested append relations.

The original coding of EquivalenceClasses didn't foresee that appendrel
child relations might themselves be appendrels; but this is possible for
example when a UNION ALL subquery scans a table with inheritance children.
The oversight led to failure to optimize ordering-related issues very well
for the grandchild tables.  After some false starts involving explicitly
flattening the appendrel representation, we found that this could be fixed
easily by removing a few implicit assumptions about appendrel parent rels
not being children themselves.

Kyotaro Horiguchi and Tom Lane, reviewed by Noah Misch
Adjust getpwuid() fix commit to display errno string on failure

This adjusts patch 613c6d26bd42dd8c2dd0664315be9551475b8864.
Improve regression test for pg_filenode_relation().

Make it print the details in case there's a failure.

Andres Freund, slightly modified by me
Force consistent row order in contrib/test_decoding regression test.
Document platform-specificity of unix_socket_permissions.

Back-patch to 8.4 (all supported versions).