]> granicus.if.org Git - postgresql/log
postgresql
6 years agoUndo extra chattiness of postmaster logs in TAP tests.
Tom Lane [Mon, 7 May 2018 19:12:01 +0000 (15:12 -0400)]
Undo extra chattiness of postmaster logs in TAP tests.

Commit 6271fceb8 changed PostgresNode.pm to force log_min_messages = debug1
in all TAP tests, without any discussion and without a concrete need for
it.  This makes some of the TAP tests noticeably slower (although much of
that may be due to poorly-written regexes), and for certain it's bloating
the buildfarm logs.  Revert the change.

Discussion: https://postgr.es/m/32459.1525657786@sss.pgh.pa.us

6 years agoUpdate oidjoins regression test for v11.
Tom Lane [Mon, 7 May 2018 18:32:04 +0000 (14:32 -0400)]
Update oidjoins regression test for v11.

Commit 86f575948 already manually updated the oidjoins test for the
new pg_constraint.conparentid => pg_constraint.oid relationship, but
failed to update findoidjoins/README, thus the apparent inconsistency
here.

Michael Paquier

Discussion: https://postgr.es/m/20180507001811.GA27389@paquier.xyz

6 years agoSuppress compiler warnings when building with --enable-dtrace.
Tom Lane [Mon, 7 May 2018 17:44:09 +0000 (13:44 -0400)]
Suppress compiler warnings when building with --enable-dtrace.

Most versions of "dtrace -h" drop const qualifiers from the declarations
of probe functions (though macOS gets it right).  This causes compiler
warnings when we pass in pointers to const.  Repair by extending our
existing post-processing of the probes.h file.  To do so, assume that all
"char *" arguments should be "const char *"; that seems reasonably safe.

Thomas Munro

Discussion: https://postgr.es/m/CAEepm=2j1pWSruQJqJ91ZDzD8w9ZZDsM4j2C6x75C-VryWg-_w@mail.gmail.com

6 years agoLast-minute updates for release notes.
Tom Lane [Mon, 7 May 2018 17:13:27 +0000 (13:13 -0400)]
Last-minute updates for release notes.

The set of functions that need parallel-safety adjustments isn't the
same in 9.6 as 10, so I shouldn't have blindly back-patched that list.
Adjust as needed.  Also, provide examples of the commands to issue.

6 years agoLast-minute updates for release notes.
Tom Lane [Mon, 7 May 2018 15:50:05 +0000 (11:50 -0400)]
Last-minute updates for release notes.

Security: CVE-2018-1115

6 years agodoc: Improve spelling and wording a bit
Peter Eisentraut [Mon, 7 May 2018 15:05:19 +0000 (11:05 -0400)]
doc: Improve spelling and wording a bit

6 years agodoc: Fix minor markup issue
Peter Eisentraut [Mon, 7 May 2018 14:16:17 +0000 (10:16 -0400)]
doc: Fix minor markup issue

There shouldn't be a line break between two adjacent tags, because that
will appear as whitespace in the output.  (The rendering engine might in
turn collapse that whitespace away, so it might not actually make a
difference, but it's more correct this way.)

6 years agoadminpack: Revoke EXECUTE on pg_logfile_rotate()
Stephen Frost [Mon, 7 May 2018 14:10:33 +0000 (10:10 -0400)]
adminpack: Revoke EXECUTE on pg_logfile_rotate()

In 9.6, we moved a number of functions over to using the GRANT system to
control access instead of having hard-coded superuser checks.

As it turns out, adminpack was creating another function in the catalog
for one of those backend functions where the superuser check was
removed, specifically pg_rotate_logfile(), but it didn't get the memo
about having to REVOKE EXECUTE on the alternative-name function
(pg_logfile_rotate()), meaning that in any installations with adminpack
on 9.6 and higher, any user is able to run the pg_logfile_rotate()
function, which then calls pg_rotate_logfile() and rotates the logfile.

Fix by adding a new version of adminpack (1.1) which handles the REVOKE.
As this function should have only been available to the superuser, this
is a security issue, albeit a minor one.

In HEAD, move the changes implemented for adminpack up to be adminpack
2.0 instead of 1.1.

Security: CVE-2018-1115

6 years agoDocumentation updates for partitioning.
Robert Haas [Mon, 7 May 2018 13:48:47 +0000 (09:48 -0400)]
Documentation updates for partitioning.

Takayuki Tsunakawa

Discussion: http://postgr.es/m/0A3221C70F24FB45833433255569204D1F965627@G01JPEXMBYT05

6 years agoRemove unused macro
Peter Eisentraut [Mon, 7 May 2018 00:10:05 +0000 (20:10 -0400)]
Remove unused macro

left behind by db3af9feb19f39827e916145f88fa5eca3130cb2

6 years agoRelease notes for 10.4, 9.6.9, 9.5.13, 9.4.18, 9.3.23.
Tom Lane [Sun, 6 May 2018 19:30:44 +0000 (15:30 -0400)]
Release notes for 10.4, 9.6.9, 9.5.13, 9.4.18, 9.3.23.

6 years agoClear severity 5 perlcritic warnings from vcregress.pl
Andrew Dunstan [Sun, 6 May 2018 11:37:05 +0000 (07:37 -0400)]
Clear severity 5 perlcritic warnings from vcregress.pl

My recent update for python3 support used some idioms that are
unapproved. This fixes them. Backpatch to all live branches like the
original.

6 years agoFix bootstrap parser so that its keywords are unreserved words.
Tom Lane [Sat, 5 May 2018 20:23:07 +0000 (16:23 -0400)]
Fix bootstrap parser so that its keywords are unreserved words.

Mark Dilger pointed out that the bootstrap parser does not allow
any of its keywords to appear as column values unless they're quoted,
and proposed dealing with that by quoting such values in genbki.pl.
Looking closer, though, we also have that problem with respect to table,
column, and type names appearing in the .bki file: the parser would fail
if any of those matched any of its keywords.  While so far there have
been no conflicts (that I've heard of), this seems like a booby trap
waiting to catch somebody.  Rather than clutter genbki.pl with enough
quoting logic to handle all that, let's make the bootstrap parser grow
up a little bit and treat its keywords as unreserved.

Experimentation shows that it's fairly easy to do so with the exception
of _null_, which I don't have a big problem with keeping as a reserved
word.  The only change needed is that we can't have the "close" command
take an optional table name: it has to either require or forbid the
table name to avoid shift/reduce conflicts.  genbki.pl has historically
always included the table name, so I took that option.

The implementation has bootscanner.l passing forward the string value
of each keyword, in case bootparse.y needs that.  This avoids needing to
know the precise spelling of each keyword in bootparse.y, which is good
because that's not always obvious from the token name.

Discussion: https://postgr.es/m/3024FC91-DB6D-4732-B31C-DF772DF039A0@gmail.com

6 years agoRevert "Test conversion of NaN between float4 and float8."
Tom Lane [Sat, 5 May 2018 17:22:11 +0000 (13:22 -0400)]
Revert "Test conversion of NaN between float4 and float8."

This reverts commit 55e0e458170c76c1a0074cd550a13ec47e38a3fa.
It's served its purpose of demonstrating what was wrong on
buildfarm member opossum.  We could consider putting some kind
of single-purpose hack into ftod() to make the test pass there;
but I don't think it's worth the trouble, since there are surely
many other places whether this platform bug could manifest.

6 years agoPut in_range_float4_float8's work in-line.
Tom Lane [Sat, 5 May 2018 17:21:50 +0000 (13:21 -0400)]
Put in_range_float4_float8's work in-line.

In commit 8b29e88cd, I'd dithered about whether to make
in_range_float4_float8 be a standalone copy of the float in-range logic
or have it punt to in_range_float8_float8.  I went with the latter, which
saves code space though at the cost of performance and readability.

However, it emerges that this tickles a compiler or hardware bug on
buildfarm member opossum.  Test results from commit 55e0e4581 show
conclusively that widening a float4 NaN to float8 produces Inf, not NaN,
on that machine; which accounts perfectly for the window RANGE test
failures it's been showing.  We can dodge this problem by making
in_range_float4_float8 be an independent function, so that it checks
for NaN inputs before widening them.

Ordinarily I'd not be very excited about working around such obviously
broken functionality; but given that this was a judgment call to begin
with, I don't mind reversing it.

6 years agoRemove extra newlines after PQerrorMessage()
Peter Eisentraut [Sat, 5 May 2018 14:51:38 +0000 (10:51 -0400)]
Remove extra newlines after PQerrorMessage()

6 years agoFirst-draft release notes for 10.4.
Tom Lane [Fri, 4 May 2018 22:56:50 +0000 (18:56 -0400)]
First-draft release notes for 10.4.

As usual, the release notes for other branches will be made by cutting
these down, but put them up for community review first.

6 years agoFix scenario where streaming standby gets stuck at a continuation record.
Heikki Linnakangas [Fri, 4 May 2018 22:34:53 +0000 (01:34 +0300)]
Fix scenario where streaming standby gets stuck at a continuation record.

If a continuation record is split so that its first half has already been
removed from the master, and is only present in pg_wal, and there is a
recycled WAL segment in the standby server that looks like it would
contain the second half, recovery would get stuck. The code in
XLogPageRead() incorrectly started streaming at the beginning of the
WAL record, even if we had already read the first page.

Backpatch to 9.4. In principle, older versions have the same problem, but
without replication slots, there was no straightforward mechanism to
prevent the master from recycling old WAL that was still needed by standby.
Without such a mechanism, I think it's reasonable to assume that there's
enough slack in how many old segments are kept around to not run into this,
or you have a WAL archive.

Reported by Jonathon Nelson. Analysis and patch by Kyotaro HORIGUCHI, with
some extra comments by me.

Discussion: https://www.postgresql.org/message-id/CACJqAM3xVz0JY1XFDKPP%2BJoJAjoGx%3DGNuOAshEDWCext7BFvCQ%40mail.gmail.com

6 years agoDon't mark pages all-visible spuriously
Alvaro Herrera [Fri, 4 May 2018 18:24:44 +0000 (15:24 -0300)]
Don't mark pages all-visible spuriously

Dan Wood diagnosed a long-standing problem that pages containing tuples
that are locked by multixacts containing live lockers may spuriously end
up as candidates for getting their all-visible flag set.  This has the
long-term effect that multixacts remain unfrozen; this may previously
pass undetected, but since commit XYZ it would be reported as
  "ERROR: found multixact 134100944 from before relminmxid 192042633"
because when a later vacuum tries to freeze the page it detects that a
multixact that should have gotten frozen, wasn't.

Dan proposed a (correct) patch that simply sets a variable to its
correct value, after a bogus initialization.  But, per discussion, it
seems better coding to avoid the bogus initializations altogether, since
they could give rise to more bugs later.  Therefore this fix rewrites
the logic a little bit to avoid depending on the bogus initializations.

This bug was part of a family introduced in 9.6 by commit a892234f830e;
later, commit 38e9f90a227d fixed most of them, but this one was
unnoticed.

Authors: Dan Wood, Pavan Deolasee, Álvaro Herrera
Reviewed-by: Masahiko Sawada, Pavan Deolasee, Álvaro Herrera
Discussion: https://postgr.es/m/84EBAC55-F06D-4FBE-A3F3-8BDA093CE3E3@amazon.com

6 years agoProvide for testing on python3 modules when under MSVC
Andrew Dunstan [Fri, 4 May 2018 19:22:48 +0000 (15:22 -0400)]
Provide for testing on python3 modules when under MSVC

This should have been done some years ago as promised in commit
c4dcdd0c2. However, better late than never.

Along the way do a little housekeeping, including using a simpler test
for the python version being tested, and removing a redundant subroutine
parameter. These changes only apply back to release 9.5.

Backpatch to all live releases.

6 years agoAllow MSYS as well as MINGW in Msys uname
Andrew Dunstan [Fri, 4 May 2018 18:54:04 +0000 (14:54 -0400)]
Allow MSYS as well as MINGW in Msys uname

Msys2's uname -s outputs a string beginning MSYS rather than MINGW as is
output by Msys. Allow either in pg_upgrade's test.sh.

Backpatch to all live branches.

6 years agoSync our copy of the timezone library with IANA release tzcode2018e.
Tom Lane [Fri, 4 May 2018 16:26:25 +0000 (12:26 -0400)]
Sync our copy of the timezone library with IANA release tzcode2018e.

The non-cosmetic changes involve teaching the "zic" tzdata compiler about
negative DST.  While I'm not currently intending that we start using
negative-DST data right away, it seems possible that somebody would try
to use our copy of zic with bleeding-edge IANA data.  So we'd better be
out in front of this change code-wise, even though it doesn't matter for
the data file we're shipping.

Discussion: https://postgr.es/m/30996.1525445902@sss.pgh.pa.us

6 years agoFix precedence problem in new Perl code.
Tom Lane [Fri, 4 May 2018 13:46:31 +0000 (09:46 -0400)]
Fix precedence problem in new Perl code.

I think this bit of commit 1f1cd9b5d didn't do quite what I meant :-(

6 years agopg_dump: Use current_database() instead of PQdb()
Peter Eisentraut [Tue, 10 Apr 2018 16:32:05 +0000 (12:32 -0400)]
pg_dump: Use current_database() instead of PQdb()

For querying pg_database about information about the database being
dumped, look up by using current_database() instead of the value
obtained from PQdb().  When using a connection proxy, the value from
PQdb() might not be the real name of the database.

6 years agoDon't truncate away non-key attributes for leftmost downlinks.
Teodor Sigaev [Fri, 4 May 2018 09:38:23 +0000 (12:38 +0300)]
Don't truncate away non-key attributes for leftmost downlinks.

nbtsort.c does not need to truncate away non-key attributes for the
minimum key of the leftmost page on a level, since this is only used to
build a minus infinity downlink for the level's leftmost page.
Truncating away non-key attributes in advance of truncating away all
attributes in _bt_sortaddtup() does not affect the correctness of CREATE
INDEX, but it is misleading.

Author: Peter Geoghegan
Discussion: https://www.postgresql.org/message-id/CAH2-WzkAS2M3ussHG-s_Av=Zo6dPjOxyu5fNRkYnxQV+YzGQ4w@mail.gmail.com

6 years agoRe-think predicate locking on GIN indexes.
Teodor Sigaev [Fri, 4 May 2018 08:27:50 +0000 (11:27 +0300)]
Re-think predicate locking on GIN indexes.

The principle behind the locking was not very well thought-out, and not
documented. Add a section in the README to explain how it's supposed to
work, and change the code so that it actually works that way.

This fixes two bugs:

1. If fast update was turned on concurrently, subsequent inserts to the
   pending list would not conflict with predicate locks that were acquired
   earlier, on entry pages. The included 'predicate-gin-fastupdate' test
   demonstrates that. To fix, make all scans acquire a predicate lock on
   the metapage. That lock represents a scan of the pending list, whether
   or not there is a pending list at the moment. Forget about the
   optimization to skip locking/checking for locks, when fastupdate=off.
2. If a scan finds no match, it still needs to lock the entry page. The
   point of predicate locks is to lock the gabs between values, whether
   or not there is a match. The included 'predicate-gin-nomatch' test
   tests that case.

In addition to those two bug fixes, this removes some unnecessary locking,
following the principle laid out in the README. Because all items in
a posting tree have the same key value, a lock on the posting tree root is
enough to cover all the items. (With a very large posting tree, it would
possibly be better to lock the posting tree leaf pages instead, so that a
"skip scan" with a query like "A & B", you could avoid unnecessary conflict
if a new tuple is inserted with A but !B. But let's keep this simple.)

Also, some spelling  fixes.

Author: Heikki Linnakangas with some editorization by me
Review: Andrey Borodin, Alexander Korotkov
Discussion: https://www.postgresql.org/message-id/0b3ad2c2-2692-62a9-3a04-5724f2af9114@iki.fi

6 years agoUpdate expected files for older Python versions
Peter Eisentraut [Fri, 4 May 2018 00:29:19 +0000 (20:29 -0400)]
Update expected files for older Python versions

neglected in commit fa03769e4c4bf0911da71fba2501006b05ea195a

6 years agoBlindly try to fix MSVC build's use of genbki.pl and Gen_fmgrtab.pl.
Tom Lane [Thu, 3 May 2018 22:47:41 +0000 (18:47 -0400)]
Blindly try to fix MSVC build's use of genbki.pl and Gen_fmgrtab.pl.

We need to use a stamp file to record the runs of these scripts, as
is done on the Unix side.  I think I got it right, but can't test.

While at it, extend this handmade dependency logic to also check the
generating script files, as the makefiles do.

Discussion: https://postgr.es/m/16925.1525376229@sss.pgh.pa.us

6 years agoAvoid overwriting unchanged output files in genbki.pl and Gen_fmgrtab.pl.
Tom Lane [Thu, 3 May 2018 22:06:45 +0000 (18:06 -0400)]
Avoid overwriting unchanged output files in genbki.pl and Gen_fmgrtab.pl.

If a particular output file already exists with the contents it should
have, leave it alone, so that its mod timestamp is not advanced.

In builds using --enable-depend, this can avoid the need to recompile .c
files whose included files didn't actually change.  It's not clear whether
it saves much of anything for users of ccache; but the cost of doing the
file comparisons seems to be negligible, so we might as well do it.

For developers using the MSVC toolchain, this will create a regression:
msvc/Solution.pm will sometimes run genbki.pl or Gen_fmgrtab.pl
unnecessarily.  I'll look into fixing that separately.

Discussion: https://postgr.es/m/16925.1525376229@sss.pgh.pa.us

6 years agoRearrange makefile rules for running Gen_fmgrtab.pl.
Tom Lane [Thu, 3 May 2018 21:54:18 +0000 (17:54 -0400)]
Rearrange makefile rules for running Gen_fmgrtab.pl.

Make these rules look more like the ones associated with genbki.pl,
to wit:

* Use a stamp file to record when we last ran the script, instead of
relying on the timestamps of the individual output files.

* Take the knowledge out of backend/Makefile and put it in utils/Makefile
where it belongs.  I moved down the handling of errcodes.h and probes.h
too, although those continue to be built by separate processes.

In itself, this is just much-needed cleanup with little practical effect.
However, by decoupling these makefile rules from the timestamps of the
generated header files, we open the door to not advancing those timestamps
unnecessarily, which will be taken advantage of by the next commit.

msvc/Solution.pm should be taught to do things similarly, but I'll leave
that for another commit.

Discussion: https://postgr.es/m/16925.1525376229@sss.pgh.pa.us

6 years agoTweak tests to support Python 3.7
Peter Eisentraut [Tue, 13 Feb 2018 21:13:20 +0000 (16:13 -0500)]
Tweak tests to support Python 3.7

Python 3.7 removes the trailing comma in the repr() of
BaseException (see <https://bugs.python.org/issue30399>), leading to
test output differences.  Work around that by composing the equivalent
test output in a more manual way.

6 years agoAdd HOLD_INTERRUPTS section into FinishPreparedTransaction.
Teodor Sigaev [Thu, 3 May 2018 17:08:29 +0000 (20:08 +0300)]
Add HOLD_INTERRUPTS section into FinishPreparedTransaction.

If an interrupt arrives in the middle of FinishPreparedTransaction
and any callback decide to call CHECK_FOR_INTERRUPTS (e.g.
RemoveTwoPhaseFile can write a warning with ereport, which checks for
interrupts) then it's possible to leave current GXact undeleted.

Backpatch to all supported branches

Stas Kelvich

Discussion: ihttps://www.postgresql.org/message-id/3AD85097-A3F3-4EBA-99BD-C38EDF8D2949@postgrespro.ru

6 years agoAvoid portability issues in autoprewarm.c.
Tom Lane [Thu, 3 May 2018 16:50:27 +0000 (12:50 -0400)]
Avoid portability issues in autoprewarm.c.

autoprewarm.c mostly considered the number of blocks it might be dealing
with as being int64.  This is unnecessary, because NBuffers is declared
as int, and there's been no suggestion that we might widen it in the
foreseeable future.  Moreover, using int64 is problematic because the
code expected INT64_FORMAT to work with fscanf(), something we don't
guarantee, and which indeed fails on some older buildfarm members.

On top of that, the module randomly used uint32 rather than int64 variables
to hold block counters in several places, so it would fail anyway if we
ever did have NBuffers wider than that; and it also supposed that pg_qsort
could sort an int64 number of elements, which is wrong on 32-bit machines
(though no doubt a 32-bit machine couldn't actually have that many
buffers).

Hence, change all these variables to plain int.

In passing, avoid shadowing one variable named i with another,
and avoid casting away const in apw_compare_blockinfo.

Discussion: https://postgr.es/m/7773.1525288909@sss.pgh.pa.us

6 years agoFix pg_dump support for pre-8.2 versions
Teodor Sigaev [Thu, 3 May 2018 15:37:34 +0000 (18:37 +0300)]
Fix pg_dump support for pre-8.2 versions

Unify indnkeys/indnatts/indnkeyatts usage  for all version of query to get
index information, remove indnkeys column  from query as unused.

Author: Marina Polyakova
Noticed by: Peter Eisentraut

6 years agoFurther improve code for probing the availability of ARM CRC instructions.
Tom Lane [Thu, 3 May 2018 15:32:57 +0000 (11:32 -0400)]
Further improve code for probing the availability of ARM CRC instructions.

Andrew Gierth pointed out that commit 1c72ec6f4 would yield the wrong
answer on big-endian ARM systems, because the data being CRC'd would be
different.  To fix that, and avoid the rather unsightly hard-wired
constant, simply compare the hardware and software implementations'
results.

While we're at it, also log the resulting decision at DEBUG1, and error
out if the hw and sw results unexpectedly differ.  Also, since this
file must compile for both frontend and backend, avoid incorrect
dependencies on backend-only headers.

In passing, add a comment to postmaster.c about when the CRC function
pointer will get initialized.

Thomas Munro, based on complaints from Andrew Gierth and Tom Lane

Discussion: https://postgr.es/m/HE1PR0801MB1323D171938EABC04FFE7FA9E3110@HE1PR0801MB1323.eurprd08.prod.outlook.com

6 years agoFix SPI error cleanup and memory leak
Peter Eisentraut [Wed, 2 May 2018 20:50:03 +0000 (16:50 -0400)]
Fix SPI error cleanup and memory leak

Since the SPI stack has been moved from TopTransactionContext to
TopMemoryContext, setting _SPI_stack to NULL in AtEOXact_SPI() leaks
memory.  In fact, we don't need to do that anymore: We just leave the
allocated stack around for the next SPI use.

Also, refactor the SPI cleanup so that it is run both at transaction end
and when returning to the main loop on an exception.  The latter is
necessary when a procedure calls a COMMIT or ROLLBACK command that
itself causes an error.

6 years agoRemove now-unnecessary cast.
Robert Haas [Thu, 3 May 2018 00:26:02 +0000 (20:26 -0400)]
Remove now-unnecessary cast.

Etsuro Fujita

Discussion: http://postgr.es/m/5AE99BA7.9060001@lab.ntt.co.jp

6 years agoImprove our method for probing the availability of ARM CRC instructions.
Tom Lane [Wed, 2 May 2018 22:06:43 +0000 (18:06 -0400)]
Improve our method for probing the availability of ARM CRC instructions.

Instead of depending on glibc's getauxval() function, just try to execute
the CRC code, and trap SIGILL if that happens.

Thomas Munro

Discussion: https://postgr.es/m/HE1PR0801MB1323D171938EABC04FFE7FA9E3110@HE1PR0801MB1323.eurprd08.prod.outlook.com

6 years agoPrevent NaN in jsonb/plpython transform
Peter Eisentraut [Wed, 2 May 2018 19:58:34 +0000 (15:58 -0400)]
Prevent NaN in jsonb/plpython transform

As in e348e7ae5727a6da8678036d748e5c5af7deb6c9 for jsonb/plperl, prevent
putting a NaN into a jsonb numeric field.

Tests for this had been removed in
6278a2a262b63faaf47eb2371f6bcb5b6e3ff118, but in case they are ever
resurrected: This would change the output of the test1nan() function to
an error.

6 years agoSuppress some compiler warnings in plperl on Windows.
Tom Lane [Wed, 2 May 2018 20:00:54 +0000 (16:00 -0400)]
Suppress some compiler warnings in plperl on Windows.

Perl's XSUB.h header defines macros to replace libc functions.  Our header
port_win32.h does something similar earlier, so XSUB.h causes compiler
warnings about macro redefinition.  Undefine our macros before including
XSUB.h.

Thomas Munro

Discussion: https://postgr.es/m/CAEepm%3D3%3DTDYEXUEcHpEx%2BTwc31wo7PA0oBAiNt6sWmq93MW02A%40mail.gmail.com

6 years agoFix assorted compiler warnings seen in the buildfarm.
Tom Lane [Wed, 2 May 2018 19:52:54 +0000 (15:52 -0400)]
Fix assorted compiler warnings seen in the buildfarm.

Failure to use DatumGetFoo/FooGetDatum macros correctly, or at all,
causes some warnings about sign conversion.  This is just cosmetic
at the moment but in principle it's a type violation, so clean up
the instances I could find.

autoprewarm.c and sharedfileset.c contained code that unportably
assumed that pid_t is the same size as int.  We've variously dealt
with this by casting pid_t to int or to unsigned long for printing
purposes; I went with the latter.

Fix uninitialized-variable warning in RestoreGUCState.  This is
a live bug in some sense, but of no great significance given that
nobody is very likely to care what "line number" is associated with
a GUC that hasn't got a source file recorded.

6 years agoFix bogus code for extracting extended-statistics data from syscache.
Tom Lane [Wed, 2 May 2018 16:22:48 +0000 (12:22 -0400)]
Fix bogus code for extracting extended-statistics data from syscache.

statext_dependencies_load and statext_ndistinct_load were not up to snuff,
in addition to being randomly different from each other.  In detail:

* Deserialize the fetched bytea value before releasing the syscache
entry, not after.  This mistake causes visible regression test failures
when running with -DCATCACHE_FORCE_RELEASE.  Since it's not exposed by
-DCLOBBER_CACHE_ALWAYS, I think there may be no production hazard here
at present, but it's at least a latent bug.

* Use DatumGetByteaPP not DatumGetByteaP to save a detoasting cycle
for short stats values; the deserialize function has to be, and is,
prepared for short-header values since its other caller uses PP.

* Use a test-and-elog for null stats values in both functions, rather
than a test-and-elog in one case and an Assert in the other.  Perhaps
Asserts would be sufficient in both cases, but I don't see a good
argument for them being different.

* Minor cosmetic changes to make these functions more visibly alike.

Backpatch to v10 where this code came in.

Amit Langote, minor additional hacking by me

Discussion: https://postgr.es/m/1349aabb-3a1f-6675-9fc0-65e2ce7491dd@lab.ntt.co.jp

6 years agodoc: Correct update on limitations of partitions
Peter Eisentraut [Wed, 2 May 2018 16:06:25 +0000 (12:06 -0400)]
doc: Correct update on limitations of partitions

Amit Langote

6 years agoRemove remaining references to version-0 calling convention in docs.
Heikki Linnakangas [Wed, 2 May 2018 14:51:11 +0000 (17:51 +0300)]
Remove remaining references to version-0 calling convention in docs.

Support for version-0 calling convention was removed in PostgreSQL v10.
Change the SPI example to use version 1 convention, so that it actually
works.

Author: John Naylor
Discussion: https://www.postgresql.org/message-id/CAJVSVGVydmhLBdm80Rw3G8Oq5TnA7eCxUv065yoZfNfLbF1tzA@mail.gmail.com

6 years agoFix some sloppiness in the new BufFileSize() and BufFileAppend() functions.
Heikki Linnakangas [Wed, 2 May 2018 14:23:13 +0000 (17:23 +0300)]
Fix some sloppiness in the new BufFileSize() and BufFileAppend() functions.

There were three related issues:

* BufFileAppend() incorrectly reset the seek position on the 'source' file.
  As a result, if you had called BufFileRead() on the file before calling
  BufFileAppend(), it got confused, and subsequent calls would read/write
  at wrong position.

* BufFileSize() did not work with files opened with BufFileOpenShared().

* FileGetSize() only worked on temporary files.

To fix, change the way BufFileSize() works so that it works on shared
files. Remove FileGetSize() altogether, as it's no longer needed. Remove
buffilesize from TapeShare struct, as the leader process can simply call
BufFileSize() to get the tape's size, there's no need to pass it through
shared memory anymore.

Discussion: https://www.postgresql.org/message-id/CAH2-WznEDYe_NZXxmnOfsoV54oFkTdMy7YLE2NPBLuttO96vTQ@mail.gmail.com

6 years agodocs: Remove tabs recently introduced by me.
Bruce Momjian [Wed, 2 May 2018 12:33:36 +0000 (08:33 -0400)]
docs:  Remove tabs recently introduced by me.

6 years agoFix compiler warning on Windows.
Tom Lane [Wed, 2 May 2018 04:25:35 +0000 (00:25 -0400)]
Fix compiler warning on Windows.

Commit 41c912cad caused MSVC to complain that not all control paths
return a value.

Thomas Munro

Discussion: https://postgr.es/m/CAEepm%3D3%3DTDYEXUEcHpEx%2BTwc31wo7PA0oBAiNt6sWmq93MW02A%40mail.gmail.com

6 years agoChange SIZEOF_BOOL to 1 for Windows.
Tom Lane [Wed, 2 May 2018 04:21:21 +0000 (00:21 -0400)]
Change SIZEOF_BOOL to 1 for Windows.

For some reason it was previously defined as 0, which is silly.  The only
effect was to disable use of <stdbool.h>, which commit b2328bf62 intended
to make possible.

Thomas Munro

Discussion: https://postgr.es/m/CAEepm%3D3%3DTDYEXUEcHpEx%2BTwc31wo7PA0oBAiNt6sWmq93MW02A%40mail.gmail.com

6 years agoFurther -Wimplicit-fallthrough cleanup.
Andres Freund [Wed, 2 May 2018 02:53:48 +0000 (19:53 -0700)]
Further -Wimplicit-fallthrough cleanup.

Tom's earlier commit in 41c912cad159 didn't update a few cases that
are only encountered with the non-standard --with-llvm config
flag. Additionally there's also one case that appears to be a
deficiency in gcc's (up to trunk as of a few days ago) detection of
"fallthrough" comments - changing the placement slightly fixes that.

Author: Andres Freund
Discussion: https://postgr.es/m/20180502003239.wfnqu7ekz7j7imm4@alap3.anarazel.de

6 years agoFix some assorted compiler warnings on Windows.
Tom Lane [Tue, 1 May 2018 23:38:26 +0000 (19:38 -0400)]
Fix some assorted compiler warnings on Windows.

Don't overflow the result type of constant expressions.  Don't negate
unsigned types.  Define HAVE_STDBOOL_H for Visual C++ 2013 and later.

Thomas Munro
Reviewed-By: Michael Paquier and Tom Lane
Discussion: https://postgr.es/m/CAEepm%3D3%3DTDYEXUEcHpEx%2BTwc31wo7PA0oBAiNt6sWmq93MW02A%40mail.gmail.com

6 years agoClean up warnings from -Wimplicit-fallthrough.
Tom Lane [Tue, 1 May 2018 23:35:08 +0000 (19:35 -0400)]
Clean up warnings from -Wimplicit-fallthrough.

Recent gcc can warn about switch-case fall throughs that are not
explicitly labeled as intentional.  This seems like a good thing,
so clean up the warnings exposed thereby by labeling all such
cases with comments that gcc will recognize.

In files that already had one or more suitable comments, I generally
matched the existing style of those.  Otherwise I went with
/* FALLTHROUGH */, which is one of the spellings approved at the
more-restrictive-than-default level -Wimplicit-fallthrough=4.
(At the default level you can also spell it /* FALL ?THRU */,
and it's not picky about case.  What you can't do is include
additional text in the same comment, so some existing comments
containing versions of this aren't good enough.)

Testing with gcc 8.0.1 (Fedora 28's current version), I found that
I also had to put explicit "break"s after elog(ERROR) or ereport(ERROR);
apparently, for this purpose gcc doesn't recognize that those don't
return.  That seems like possibly a gcc bug, but it's fine because
in most places we did that anyway; so this amounts to a visit from the
style police.

Discussion: https://postgr.es/m/15083.1525207729@sss.pgh.pa.us

6 years agoImprove representation of 'moved partitions' indicator on deleted tuples.
Andres Freund [Tue, 1 May 2018 20:30:12 +0000 (13:30 -0700)]
Improve representation of 'moved partitions' indicator on deleted tuples.

Previously a tuple that has been moved to a different partition (see
f16241bef7c), set the block number on the old tuple to an invalid
value to indicate that fact. But the tuple offset was left
untouched. That turned out to trigger a wal_consistency_checking
failure as reported by Peter Geoghegan, as the offset wasn't
always overwritten during WAL replay.

Heikki observed that we're wasting valuable data by not putting
information also in the offset. Thus set that to
MovedPartitionsOffsetNumber when a tuple indicates it has moved.

We continue to set the block number to MovedPartitionsBlockNumber, as
that seems more likely to cause problems for code not updated to know
about moved tuples.

As t_ctid's offset number is now always set, this refinement also
fixes the wal_consistency_checking issue.

This technically is a minor disk format break, with previously created
moved tuples not being recognized anymore. But since there not even
has been a beta release since f16241bef7c...

Reported-By: Peter Geoghegan
Author: Heikki Linnakangas, Amul Sul
Discussion: https://postgr.es/m/CAH2-Wzm9ty+1BX7-GMNJ=xPRg67oJTVeDNdA9LSyJJtMgRiCMA@mail.gmail.com

6 years agoFix interaction of foreign tuple routing with remote triggers.
Robert Haas [Tue, 1 May 2018 17:21:46 +0000 (13:21 -0400)]
Fix interaction of foreign tuple routing with remote triggers.

Without these fixes, changes to the inserted tuple made by remote
triggers are ignored when building local RETURNING tuples.

In the core code, call ExecInitRoutingInfo at a later point from
within ExecInitPartitionInfo so that the FDW callback gets invoked
after the returning list has been built.  But move CheckValidResultRel
out of ExecInitRoutingInfo so that it can happen at an earlier stage.

In postgres_fdw, refactor assorted deparsing functions to work with
the RTE rather than the PlannerInfo, which saves us having to
construct a fake PlannerInfo in cases where we don't have a real one.
Then, we can pass down a constructed RTE that yields the correct
deparse result when no real one exists.  Unfortunately, this
necessitates a hack that understands how the core code manages RT
indexes for update tuple routing, which is ugly, but we don't have a
better idea right now.

Original report, analysis, and patch by Etsuro Fujita.  Heavily
refactored by me.  Then worked over some more by Amit Langote.

Discussion: http://postgr.es/m/5AD4882B.10002@lab.ntt.co.jp

6 years agoRemove jsonb_plperl test cases for Inf/NaN conversions.
Tom Lane [Tue, 1 May 2018 17:21:16 +0000 (13:21 -0400)]
Remove jsonb_plperl test cases for Inf/NaN conversions.

It turns out that old Perl versions (before about 5.10) don't have any
very reliable way to generate Inf or NaN numeric values.  Getting around
that would require way more work than is really justified to test the
code involved, so let's just drop these new test cases.

Discussion: https://postgr.es/m/28585.1525131438@sss.pgh.pa.us

6 years agoRemove investigative code for can't-reattach-to-shared-memory errors.
Tom Lane [Tue, 1 May 2018 17:06:31 +0000 (13:06 -0400)]
Remove investigative code for can't-reattach-to-shared-memory errors.

Revert commits 23078689a73042b8d1ce07aff48f7df8043f6ba0cc4bd,
eb16011f468e7e973d63ca350ef.  We still have a problem here, but
somebody who's actually a Windows developer will need to spend time
on it.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoDocument that subscription tests require hstore
Peter Eisentraut [Tue, 1 May 2018 14:33:02 +0000 (10:33 -0400)]
Document that subscription tests require hstore

6 years agodoc comments: rendering engines are another UTF8 restriction
Bruce Momjian [Tue, 1 May 2018 14:17:55 +0000 (10:17 -0400)]
doc comments:  rendering engines are another UTF8 restriction

6 years agodocs comments: clarify why not to use UTF8 still in docs
Bruce Momjian [Tue, 1 May 2018 13:26:11 +0000 (09:26 -0400)]
docs comments:  clarify why not to use UTF8 still in docs

Back branches still are SGML.

6 years agodoc: Update limitations of partitions
Peter Eisentraut [Tue, 1 May 2018 11:48:51 +0000 (07:48 -0400)]
doc: Update limitations of partitions

David Rowley, Amit Langote

6 years agoTweak new jsonb_plperl test cases to work with old Perl versions.
Tom Lane [Tue, 1 May 2018 03:58:48 +0000 (23:58 -0400)]
Tweak new jsonb_plperl test cases to work with old Perl versions.

The previous coding here didn't actually produce Inf or NaN double
values in Perl versions 5.8.x.  Adopt a suggestion from stackoverflow.

Discussion: https://postgr.es/m/28585.1525131438@sss.pgh.pa.us

6 years agoDoes it help to wait before reattaching?
Tom Lane [Tue, 1 May 2018 00:09:31 +0000 (20:09 -0400)]
Does it help to wait before reattaching?

Revert the map/unmap dance I tried in commit 73042b8d1; that helps
not at all.

Instead, speculate that the unwanted allocation is being done on
another thread, and thus timing variations explain the apparent
unpredictability.  Temporarily add a 1-second sleep before the
VirtualFree call, in hopes that any such other threads will
quiesce and not jog our elbow.

This is obviously not a desirable long-term fix, but as a means of
investigation it seems useful.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoMap and unmap the shared memory block before risking VirtualFree.
Tom Lane [Mon, 30 Apr 2018 21:07:14 +0000 (17:07 -0400)]
Map and unmap the shared memory block before risking VirtualFree.

The idea here is to get Windows' userspace infrastructure to allocate
whatever space it needs for MapViewOfFileEx() before we release the
locked-down space that we want to map the shared memory block into.

This is a fairly brute-force attempt, and would likely (for example)
fail with large shared memory on 32-bit Windows.  We could perhaps
ameliorate that by mapping only part of the shared memory block in
this way, but for the moment I just want to see if this approach
will fix dory's problem.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoFurther effort at preventing memory map dump from affecting the results.
Tom Lane [Mon, 30 Apr 2018 20:19:51 +0000 (16:19 -0400)]
Further effort at preventing memory map dump from affecting the results.

Rather than elog'ing immediately, push the map data into a preallocated
StringInfo.  Perhaps this will prevent some of the mid-operation
allocations that are evidently happening now.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoRemove plperl isnan hack
Peter Eisentraut [Mon, 30 Apr 2018 18:34:05 +0000 (14:34 -0400)]
Remove plperl isnan hack

The code previously undefined isnan because of a compiler warning on
MinGW.  Since we now need to use isnan, we can't do that anymore.

We might need a different solution if the compiler warning is too
annoying.

6 years agoWrite error messages about duplicate OIDs to stderr
Peter Eisentraut [Mon, 30 Apr 2018 18:18:46 +0000 (14:18 -0400)]
Write error messages about duplicate OIDs to stderr

6 years agoRemove "Generating" output from catalog scripts
Peter Eisentraut [Mon, 30 Apr 2018 18:18:07 +0000 (14:18 -0400)]
Remove "Generating" output from catalog scripts

So by default, they don't output anything if everything is well.

Discussion: https://www.postgresql.org/message-id/867f8a1a-6cf0-d835-78d8-0844e4936241%402ndquadrant.com

6 years agoDon't do logical replication of TRUNCATE of zero tables
Peter Eisentraut [Mon, 30 Apr 2018 17:49:20 +0000 (13:49 -0400)]
Don't do logical replication of TRUNCATE of zero tables

When due to publication configuration, a TRUNCATE change ends up with
zero tables to be published, don't send the message out, just skip it.
It's not wrong, but obviously useless overhead.

6 years agoPrevent infinity and NaN in jsonb/plperl transform
Peter Eisentraut [Mon, 30 Apr 2018 16:28:45 +0000 (12:28 -0400)]
Prevent infinity and NaN in jsonb/plperl transform

jsonb uses numeric internally, and numeric can store NaN, but that is
not allowed by jsonb on input, so we shouldn't store it.  Also prevent
infinity to get a consistent error message.  (numeric input would reject
infinity anyway.)

Reported-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
6 years agoRemove Windows module-list-dumping code.
Tom Lane [Mon, 30 Apr 2018 17:20:13 +0000 (13:20 -0400)]
Remove Windows module-list-dumping code.

This code is evidently allocating memory and thus confusing matters
even more.  Let's see whether we can learn anything with
just VirtualQuery.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoclean up pg_upgrade tmp_check under MSVC
Andrew Dunstan [Mon, 30 Apr 2018 16:43:57 +0000 (12:43 -0400)]
clean up pg_upgrade tmp_check under MSVC

6 years agoIgnore file generated during pg_upgrade testing
Andrew Dunstan [Mon, 30 Apr 2018 16:39:29 +0000 (12:39 -0400)]
Ignore file generated during pg_upgrade testing

6 years agoDump full memory maps around failing Windows reattach code.
Tom Lane [Mon, 30 Apr 2018 15:16:21 +0000 (11:16 -0400)]
Dump full memory maps around failing Windows reattach code.

This morning's results from buildfarm member dory make it pretty
clear that something is getting mapped into the just-freed space,
but not what that something is.  Replace my minimalistic probes
with a full dump of the process address space and module space,
based on Noah's work at
<20170403065106.GA2624300%40tornado.leadboat.com>

This is all (probably) to get reverted once we have fixed the
problem, but for now we need information.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoFix bogus list-iteration code in pg_regress.c, affecting ecpg tests only.
Tom Lane [Mon, 30 Apr 2018 01:56:27 +0000 (21:56 -0400)]
Fix bogus list-iteration code in pg_regress.c, affecting ecpg tests only.

While looking at a recent buildfarm failure in the ecpg tests, I wondered
why the pg_regress output claimed the stderr part of the test failed, when
the regression diffs were clearly for the stdout part.  Looking into it,
the reason is that pg_regress.c's logic for iterating over three parallel
lists is wrong, and has been wrong since it was written: it advances the
"tag" pointer at a different place in the loop than the other two pointers.
Fix that.

6 years agoGet still more info about Windows can't-reattach-to-shared-memory errors.
Tom Lane [Mon, 30 Apr 2018 00:41:19 +0000 (20:41 -0400)]
Get still more info about Windows can't-reattach-to-shared-memory errors.

After some thought about the info captured so far, it seems possible
that MapViewOfFileEx is itself causing some DLL to get loaded into
the space just freed by VirtualFree.  The previous commit here didn't
capture enough info to really prove the case for that, so let's add
one more VirtualQuery in between those steps.  Also, be sure to
capture the post-Map state before we emit any log entries, just in
case elog() is invoking some code not previously loaded.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoAvoid wrong results for power() with NaN input on more platforms.
Tom Lane [Sun, 29 Apr 2018 22:15:16 +0000 (18:15 -0400)]
Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

6 years agoGet more info about Windows can't-reattach-to-shared-memory errors.
Tom Lane [Sun, 29 Apr 2018 20:02:45 +0000 (16:02 -0400)]
Get more info about Windows can't-reattach-to-shared-memory errors.

Commit 63ca350ef neglected to probe the state of things *before*
the VirtualFree call, which now looks like it might be interesting.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoUpdate time zone data files to tzdata release 2018d.
Tom Lane [Sun, 29 Apr 2018 19:50:08 +0000 (15:50 -0400)]
Update time zone data files to tzdata release 2018d.

DST law changes in Palestine and Antarctica (Casey Station).  Historical
corrections for Portugal and its colonies, as well as Enderbury, Jamaica,
Turks & Caicos Islands, and Uruguay.

6 years agoAvoid wrong results for power() with NaN input on some platforms.
Tom Lane [Sun, 29 Apr 2018 19:21:44 +0000 (15:21 -0400)]
Avoid wrong results for power() with NaN input on some platforms.

Per spec, the result of power() should be NaN if either input is NaN.
It appears that on some versions of Windows, the libc function does
return NaN, but it also sets errno = EDOM, confusing our code that
attempts to work around shortcomings of other platforms.  Hence, add
guard tests to avoid substituting a wrong result for the right one.

It's been like this for a long time (and the odd behavior only appears
in older MSVC releases, too) so back-patch to all supported branches.

Dang Minh Huong, reviewed by David Rowley

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

6 years agoCosmetic improvement: use BKI_DEFAULT and BKI_LOOKUP in pg_language.
Tom Lane [Sun, 29 Apr 2018 17:26:26 +0000 (13:26 -0400)]
Cosmetic improvement: use BKI_DEFAULT and BKI_LOOKUP in pg_language.

The point of this is not really to remove redundancy in pg_language.dat;
with only three entries, it's hardly worth it.  Rather, it is to get
to a point where there are exactly zero hard-coded numeric pg_proc OID
references in the catalog .dat files.  The lanvalidator column was the
only remaining location of such references, and it seems like a good
thing for future-proofing reasons to make it not be a special case.

There are still a few places in the .dat files with numeric OID references
to other catalogs, but after review I don't see any that seem worth
changing at present.  In each case there are just too few entries to make
it worth the trouble to create lookup infrastructure.

This doesn't change the emitted postgres.bki file, so no catversion bump.

6 years agoIn AtEOXact_Files, complain if any files remain unclosed at commit.
Tom Lane [Sat, 28 Apr 2018 21:45:02 +0000 (17:45 -0400)]
In AtEOXact_Files, complain if any files remain unclosed at commit.

This change makes this module act more like most of our other low-level
resource management modules.  It's a caller error if something is not
explicitly closed by the end of a successful transaction, so issue
a WARNING about it.  This would not actually have caught the file leak
bug fixed in commit 231bcd080, because that was in a transaction-abort
path; but it still seems like a good, and pretty cheap, cross-check.

Discussion: https://postgr.es/m/152056616579.4966.583293218357089052@wrigleys.postgresql.org

6 years agoFix incorrect field type for PlannedStmt.jitFlags in outfuncs/readfuncs.
Tom Lane [Sat, 28 Apr 2018 20:46:24 +0000 (16:46 -0400)]
Fix incorrect field type for PlannedStmt.jitFlags in outfuncs/readfuncs.

This field was a bool at one point, but now it's an int.
Spotted by Hari Babu; trivial patch is by Ashutosh Bapat.

Discussion: https://postgr.es/m/CAJrrPGedKiFE2fqntSauUfhapCksOJzam+QtHfSgx86LhXLeOQ@mail.gmail.com

6 years agoTweak reformat_dat_file.pl to make it more easily hand-invokable.
Tom Lane [Sat, 28 Apr 2018 20:09:03 +0000 (16:09 -0400)]
Tweak reformat_dat_file.pl to make it more easily hand-invokable.

Use the same code we already applied in duplicate_oids and unused_oids
to let this script find Catalog.pm without help.  This removes the need
to supply a -I switch in most cases.

Also, mark the script executable, again to follow the precedent of
duplicate_oids and unused_oids.  Now you can just do
"./reformat_dat_file.pl pg_proc.dat"
if you want to reformat only one or a few .dat files rather than all.

It'd be possible to remove the -I switches in the Makefile's convenience
targets, but I chose to leave them: they don't hurt anything, and it's
possible that in weird VPATH situations they might be of value.

6 years agoClarify handling of special-case values in bootstrap catalog data.
Tom Lane [Sat, 28 Apr 2018 19:27:16 +0000 (15:27 -0400)]
Clarify handling of special-case values in bootstrap catalog data.

I (tgl) originally coded the special case for pg_proc.pronargs as
though it were a kind of default value.  It seems better though to
treat computable columns as an independent concern: this makes the
code clearer, and probably a bit faster too since we needn't do
work inside the per-column loop.

Improve related comments, as well, in the expectation that there
might be more cases like this in future.

John Naylor, some additional comment-hacking by me

Discussion: https://postgr.es/m/CAJVSVGW-D7OobzU=dybVT2JqZAx-4X1yvBJdavBmqQL05Q6CLw@mail.gmail.com

6 years agoUn-break contrib install with llvm.
Tom Lane [Sat, 28 Apr 2018 18:45:39 +0000 (14:45 -0400)]
Un-break contrib install with llvm.

Apparently $(foreach ... $(call install_llvm_module,...)) doesn't work
too well without a blank line ending the install_llvm_module macro.
The previous coding hackishly dodged this problem with some parens,
but that's not really a good solution because make misunderstands
where the command boundaries are that way.

Discussion: https://postgr.es/m/20180428073935.GB1736@paquier.xyz

6 years agoMinor cleanups for install_llvm_module/uninstall_llvm_module Make macros.
Tom Lane [Sat, 28 Apr 2018 18:02:57 +0000 (14:02 -0400)]
Minor cleanups for install_llvm_module/uninstall_llvm_module Make macros.

Don't put comments inside the macros, per complaint from Michael Paquier.

Quote target directory path with single quotes, not double; that seems
to be our project standard.  Not quoting it at all definitely isn't
per standard.

Remove excess slash in one instance of path.

Remove useless semicolon.

Discussion: https://postgr.es/m/20180428073935.GB1736@paquier.xyz

6 years agoAssorted minor doc/comment fixes.
Tom Lane [Sat, 28 Apr 2018 15:46:15 +0000 (11:46 -0400)]
Assorted minor doc/comment fixes.

Identify pg_replication_origin as a shared catalog in catalogs.sgml,
using the same boilerplate wording used for most other shared catalogs
(and tweak another place where someone had randomly deviated from
that boilerplate).

Make an example in mmgr/README more consistent with surrounding text.

Update an obsolete cross-reference in a comment in storage/block.h.

Zhuo Ql

Discussion: https://postgr.es/m/44296255.1819230.1524889719001@mail.yahoo.com

6 years agoTry to get some info about Windows can't-reattach-to-shared-memory errors.
Tom Lane [Sat, 28 Apr 2018 01:59:58 +0000 (21:59 -0400)]
Try to get some info about Windows can't-reattach-to-shared-memory errors.

Add some debug printouts focused on the idea that MapViewOfFileEx might
be rounding its virtual memory allocation up more than we expect (and,
in particular, more than VirtualAllocEx does).

Once we've seen what this reports in one of the failures on buildfarm
members dory or jacana, we might revert this ... or perhaps just
decrease the log level.

Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us

6 years agoAdjust hints and docs to suggest CREATE EXTENSION not CREATE LANGUAGE.
Tom Lane [Fri, 27 Apr 2018 17:42:03 +0000 (13:42 -0400)]
Adjust hints and docs to suggest CREATE EXTENSION not CREATE LANGUAGE.

The core PLs have been extension-ified for seven years now, and we can
reasonably hope that all out-of-core PLs have been too.  So adjust a few
places that were still recommending CREATE LANGUAGE as the user-level
way to install a PL.

Discussion: https://postgr.es/m/CA+TgmoaJTUDMSuSCg4k08Dv8vhbrJq9nP3ZfPbmysVz_616qxw@mail.gmail.com

6 years agoperltidy: Add option --nooutdent-long-comments
Peter Eisentraut [Thu, 26 Apr 2018 18:13:46 +0000 (14:13 -0400)]
perltidy: Add option --nooutdent-long-comments

6 years agoperltidy: Add option --nooutdent-long-quotes
Peter Eisentraut [Thu, 26 Apr 2018 15:52:52 +0000 (11:52 -0400)]
perltidy: Add option --nooutdent-long-quotes

6 years agoperltidy: Don't write backup files
Peter Eisentraut [Wed, 21 Mar 2018 14:09:37 +0000 (10:09 -0400)]
perltidy: Don't write backup files

Newer perltidy versions can just avoid writing backup files, so we don't
need the old dance of deleting them afterwards.  Supported since 20120619.

https://metacpan.org/source/SHANCOCK/Perl-Tidy-20120619/CHANGES#L61

6 years agoRemove outdated comment on how to set logtape's read buffer size.
Heikki Linnakangas [Fri, 27 Apr 2018 06:31:43 +0000 (09:31 +0300)]
Remove outdated comment on how to set logtape's read buffer size.

Commit b75f467b6e removed the LogicalTapeAssignReadBufferSize() function,
but forgot to update this comment. The read buffer size is an argument to
LogicalTapeRewindForRead() now. Doesn't seem worth going into the details
in the file header comment, so remove the outdated sentence altogether.

6 years agoC comment: add description of root_tuple_slot
Bruce Momjian [Thu, 26 Apr 2018 18:54:46 +0000 (14:54 -0400)]
C comment:  add description of root_tuple_slot

Reported-by: Amit Langote
Discussion: https://postgr.es/m/d2e6674c-c5c6-fe89-1d0b-3534b9db0476@lab.ntt.co.jp

6 years agoPost-feature-freeze pgindent run.
Tom Lane [Thu, 26 Apr 2018 18:47:16 +0000 (14:47 -0400)]
Post-feature-freeze pgindent run.

Discussion: https://postgr.es/m/15719.1523984266@sss.pgh.pa.us

6 years agoPreliminary work for pgindent run.
Tom Lane [Thu, 26 Apr 2018 18:45:04 +0000 (14:45 -0400)]
Preliminary work for pgindent run.

Update typedefs.list from current buildfarm results.  Adjust pgindent's
typedef blacklist to block some more unfortunate typedef names that have
snuck in since last time.  Manually tweak a few places where I didn't
like the initial results of pgindent'ing.

6 years agoAvoid parsing catalog data twice during BKI file construction.
Tom Lane [Thu, 26 Apr 2018 17:22:27 +0000 (13:22 -0400)]
Avoid parsing catalog data twice during BKI file construction.

In the wake of commit 5602265f7, we were doing duplicate-OID detection
quite inefficiently, by invoking duplicate_oids which does all the same
parsing of catalog headers and .dat files as genbki.pl does.  That adds
under half a second on modern machines, but quite a bit more on slow
buildfarm critters, so it seems worth avoiding.  Let's just extend
genbki.pl a little so it can also detect duplicate OIDs, and remove
the duplicate_oids call from the build process.

(This also means that duplicate OID detection will happen during
Windows builds, which AFAICS it didn't before.)

This makes the use-case for duplicate_oids a bit dubious, but it's
possible that people will still want to run that check without doing
a whole build run, so let's keep that script.

In passing, move down genbki.pl's creation of its temp output files
so that it doesn't happen until after we've done parsing and validation
of the input.  This avoids leaving a lot of clutter around after a
failure.

John Naylor and Tom Lane

Discussion: https://postgr.es/m/37D774E4-FE1F-437E-B3D2-593F314B7505@postgrespro.ru

6 years agoFix duplicate_oids and unused_oids so user needn't cd to catalog dir.
Tom Lane [Thu, 26 Apr 2018 15:19:52 +0000 (11:19 -0400)]
Fix duplicate_oids and unused_oids so user needn't cd to catalog dir.

Previously, you had to cd into src/include/catalog before running either
of these scripts.  That's a bit tedious, so let's make the scripts do it
for you.

In passing, improve the initial comments in both scripts.  Also remove
unused_oids' code to complain about duplicate oids.  That was added in
yesterday's commit 5602265f7, but on second thought we shouldn't be
randomly redefining the script's behavior that way.

John Naylor and Tom Lane

Discussion: https://postgr.es/m/37D774E4-FE1F-437E-B3D2-593F314B7505@postgrespro.ru

6 years agodocs: remove "III" version text from pgAdmin link
Bruce Momjian [Thu, 26 Apr 2018 15:10:43 +0000 (11:10 -0400)]
docs:  remove "III" version text from pgAdmin link

Reported-by: vodevsh@gmail.com
Discussion: https://postgr.es/m/152404286919.19366.7988650271505173666@wrigleys.postgresql.org

Backpatch-through: 9.3

6 years agoCorrect pg_recvlogical server version test.
Noah Misch [Thu, 26 Apr 2018 01:50:29 +0000 (18:50 -0700)]
Correct pg_recvlogical server version test.

The predecessor test boiled down to "PQserverVersion(NULL) >= 100000",
which is always false.  No release includes that, so it could not have
reintroduced CVE-2018-1058.  Back-patch to 9.4, like the addition of the
predecessor in commit 8d2814f274def85f39fbe997d454b01628cb5667.

Discussion: https://postgr.es/m/20180422215551.GB2676194@rfd.leadboat.com

6 years agoConvert unused_oids and duplicate_oids to use Catalog.pm infrastructure.
Tom Lane [Wed, 25 Apr 2018 20:01:47 +0000 (16:01 -0400)]
Convert unused_oids and duplicate_oids to use Catalog.pm infrastructure.

unused_oids was previously a shell script, which of course didn't work at
all on Windows.  Also, commit 372728b0d introduced some other portability
problems, as complained of by Stas Kelvich.  We can improve matters by
converting it to Perl.

While we're at it, let's future-proof both this script and duplicate_oids
to use Catalog.pm rather than having a bunch of ad-hoc logic for parsing
catalog headers and .dat files.  These scripts are thereby a bit slower,
which doesn't seem like a problem for typical manual use.  It is a little
annoying for buildfarm purposes, but we should be able to fix that case
by having genbki.pl make the check instead of parsing the headers twice.
(That's not done in this commit, though.)

Stas Kelvich, adjusted a bit by me

Discussion: https://postgr.es/m/37D774E4-FE1F-437E-B3D2-593F314B7505@postgrespro.ru