]> granicus.if.org Git - postgresql/log
postgresql
6 years agoMerge near-duplicate code in RI triggers.
Tom Lane [Sat, 18 Nov 2017 21:24:05 +0000 (16:24 -0500)]
Merge near-duplicate code in RI triggers.

Merge ri_restrict_del and ri_restrict_upd into one function ri_restrict.
Create a function ri_setnull that is the common implementation of
RI_FKey_setnull_del and RI_FKey_setnull_upd.  Likewise create a function
ri_setdefault that is the common implementation of RI_FKey_setdefault_del
and RI_FKey_setdefault_upd.  All of these pairs of functions were identical
except for needing to check for no-actual-key-change in the UPDATE cases;
the one extra if-test is a small price to pay for saving so much code.

Aside from removing about 400 lines of essentially duplicate code, this
allows us to recognize that we were uselessly caching two identical plans
whenever there were pairs of triggers using these duplicated functions
(which is likely very common).

Ildar Musin, reviewed by Ildus Kurbangaliev

Discussion: https://postgr.es/m/ca7064a7-6adc-6f22-ca47-8615ba9425a5@postgrespro.ru

6 years agoConsistently catch errors from Python _New() functions
Peter Eisentraut [Tue, 31 Oct 2017 14:49:36 +0000 (10:49 -0400)]
Consistently catch errors from Python _New() functions

Python Py*_New() functions can fail and return NULL in out-of-memory
conditions.  The previous code handled that inconsistently or not at
all.  This change organizes that better.  If we are in a function that
is called from Python, we just check for failure and return NULL
ourselves, which will cause any exception information to be passed up.
If we are called from PostgreSQL, we consistently create an "out of
memory" error.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
6 years agoImprove to_date/to_number/to_timestamp behavior with multibyte characters.
Tom Lane [Sat, 18 Nov 2017 17:42:52 +0000 (12:42 -0500)]
Improve to_date/to_number/to_timestamp behavior with multibyte characters.

The documentation says that these functions skip one input character
per literal (non-pattern) format character.  Actually, though, they
skipped one input *byte* per literal *byte*, which could be hugely
confusing if either data or format contained multibyte characters.

To fix, adjust the FormatNode representation and parse_format() so
that multibyte format characters are stored as one FormatNode not
several, and adjust the data-skipping bits to advance by pg_mblen()
not necessarily one byte.  There's no user-visible behavior change
on the to_char() side, although the internal representation changes.

Commit e87d4965b had already fixed most places where we skip characters
on the basis of non-literal format patterns to advance by characters
not bytes, but this gets one more place, the SKIP_THth macro.  I think
everything in formatting.c gets that right now.

It'd be nice to have some regression test cases covering this behavior;
but of course there's no way to do so in an encoding-agnostic way, and
many of the interesting aspects would also require unportable locale
selections.  So I've not bothered here.

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

6 years agoFix quoted-substring handling in format parsing for to_char/to_number/etc.
Tom Lane [Sat, 18 Nov 2017 17:16:37 +0000 (12:16 -0500)]
Fix quoted-substring handling in format parsing for to_char/to_number/etc.

This code evidently intended to treat backslash as an escape character
within double-quoted substrings, but it was sufficiently confused that
cases like ..."foo\\"... did not work right: the second backslash
managed to quote the double-quote after it, despite being quoted itself.
Rewrite to get that right, while preserving the existing behavior
outside double-quoted substrings, which is that backslash isn't special
except in the combination \".

Comparing to Oracle, it seems that their version of to_char() for
timestamps allows literal alphanumerics only within double quotes, while
non-alphanumerics are allowed outside quotes; backslashes aren't special
anywhere; there is no way at all to emit a literal double quote.
(Bizarrely, their to_char() for numbers is different; it doesn't allow
literal text at all AFAICT.)  The fact that they don't treat backslash
as special justifies our existing behavior for backslash outside double
quotes.  I considered making backslash inside double quotes act the same
way (ie, special only if before "), which in a green field would be a
more consistent behavior.  But that would likely break more existing SQL
code than what this patch does.

Add some test cases illustrating this behavior.  (Only the last new
case actually changes behavior in this commit.)

Little of this behavior was documented, either, so fix that.

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

6 years agoSupport channel binding 'tls-unique' in SCRAM
Peter Eisentraut [Sat, 18 Nov 2017 15:07:57 +0000 (10:07 -0500)]
Support channel binding 'tls-unique' in SCRAM

This is the basic feature set using OpenSSL to support the feature.  In
order to allow the frontend and the backend to fetch the sent and
expected TLS Finished messages, a PG-like API is added to be able to
make the interface pluggable for other SSL implementations.

This commit also adds a infrastructure to facilitate the addition of
future channel binding types as well as libpq parameters to control the
SASL mechanism names and channel binding names.  Those will be added by
upcoming commits.

Some tests are added to the SSL test suite to test SCRAM authentication
with channel binding.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
6 years agoUpdate postgresql.conf.sample comment for bgwriter_lru_maxpages
Robert Haas [Fri, 17 Nov 2017 19:52:00 +0000 (14:52 -0500)]
Update postgresql.conf.sample comment for bgwriter_lru_maxpages

Commit 14ca9abfbe4643408ad6ed3279f2f6366cafb3f1 should have done
this, but did not.

Jeff Janes

Discussion: http://postgr.es/m/CAMkU=1yWOvL+YFYzGM9yXSoWjxr_5_Ny78pPzLKQCkfgB7H-JQ@mail.gmail.com

6 years agoRemove contrib/start-scripts/osx/.
Tom Lane [Fri, 17 Nov 2017 17:53:20 +0000 (12:53 -0500)]
Remove contrib/start-scripts/osx/.

Since those scripts haven't worked at all in macOS releases of 2014
and later, and aren't the recommended way to do it on any release
since 2005, there seems little point carrying them into the future.
It's very unlikely that anyone would be installing PG >= 11 on a
macOS release where they couldn't use contrib/start-scripts/macos/.

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

6 years agoProvide modern examples of how to auto-start Postgres on macOS.
Tom Lane [Fri, 17 Nov 2017 17:46:52 +0000 (12:46 -0500)]
Provide modern examples of how to auto-start Postgres on macOS.

The scripts in contrib/start-scripts/osx don't work at all on macOS
10.10 (Yosemite) or later, because they depend on SystemStarter which
Apple deprecated long ago and removed in 10.10.  Add a new subdirectory
contrib/start-scripts/macos with scripts that use the newer launchd
infrastructure.

Since this problem is independent of which Postgres version you're using,
back-patch to all supported branches.

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

6 years agoPrevent to_number() from losing data when template doesn't match exactly.
Tom Lane [Fri, 17 Nov 2017 17:04:06 +0000 (12:04 -0500)]
Prevent to_number() from losing data when template doesn't match exactly.

Non-data template patterns would consume characters whether or not those
characters were what the pattern expected, for example
SELECT TO_NUMBER('1234', '9,999');
produced 134 because the '2' got eaten by the comma pattern.  This seems
undesirable, not least because it doesn't happen in Oracle.  For the ','
and 'G' template patterns, we can fix this by consuming characters only
if they match what the pattern would output.  For non-data patterns such
as 'L' and 'TH', it seems impractical to tighten things up to the point of
consuming only exact matches to what the pattern would output; but we can
improve matters quite a lot by redefining the behavior as "consume only
characters that aren't digits, signs, decimal point, or comma".

Also, fix it so that the behavior is to consume the number of *characters*
the pattern would output, not the number of *bytes*.  The old coding would
do surprising things with non-ASCII currency symbols, for example.  (It
would be good to apply that rule for literal text as well, but this commit
only fixes it for non-data patterns.)

Oliver Ford, reviewed by Thomas Munro and Nathan Wagner, and whacked around
a bit more by me

Discussion: https://postgr.es/m/CAGMVOdvpbMqPf9XWNzOwBpzJfErkydr_fEGhmuDGa015z97mwg@mail.gmail.com

6 years agoSet proargmodes for satisfies_hash_partition.
Robert Haas [Fri, 17 Nov 2017 16:53:00 +0000 (11:53 -0500)]
Set proargmodes for satisfies_hash_partition.

It appears that proargmodes should always be set for variadic
functions, but satifies_hash_partition had it as NULL.  In addition to
fixing the problem, add a regression test to guard against future
mistakes of this type.

6 years agoRemove BufFile's isTemp flag.
Andres Freund [Fri, 17 Nov 2017 01:52:57 +0000 (17:52 -0800)]
Remove BufFile's isTemp flag.

The isTemp flag controls whether buffile.c chops BufFile data up into
1GB segments on disk.  Since it was badly named and always true, get
rid of it.

Author: Thomas Munro (based on suggestion by Peter Geoghegan)
Reviewed-By: Peter Geoghegan, Andres Freund
Discussion: https://postgr.es/m/CAH2-Wz%3D%2B9Rfqh5UdvdW9rGezdhrMGGH-JL1X9FXXVZdeeGeOJA%40mail.gmail.com

6 years agoProvide DSM segment to ExecXXXInitializeWorker functions.
Andres Freund [Fri, 17 Nov 2017 01:28:11 +0000 (17:28 -0800)]
Provide DSM segment to ExecXXXInitializeWorker functions.

Previously, executor nodes running in parallel worker processes didn't
have access to the dsm_segment object used for parallel execution.  In
order to support resource management based on DSM segment lifetime,
they need that.  So create a ParallelWorkerContext object to hold it
and pass it to all InitializeWorker functions.

Author: Thomas Munro
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/CAEepm=2W=cOkiZxcg6qiFQP-dHUe09aqTrEMM7yJDrHMhDv_RA@mail.gmail.com

6 years agoClean up warnings in MinGW builds.
Tom Lane [Thu, 16 Nov 2017 22:57:38 +0000 (17:57 -0500)]
Clean up warnings in MinGW builds.

Experimentation with modern MinGW (specifically the 5.0.2 version packaged
for Fedora 26) shows that its version of sys/stat.h *does* provide S_IRGRP
and friends, contrary to the expectation of win32_port.h.  This results in
an astonishing number of compiler warnings, and perhaps in incorrect code
--- I'm not sure if the nonzero values supplied by MinGW's header actually
do anything.  Hence, adjust win32_port.h to only define these macros if
<sys/stat.h> doesn't.

This might be worth back-patching, but given the lack of complaints so
far, I'm not too excited about it.

6 years agoMake PL/Python handle domain-type conversions correctly.
Tom Lane [Thu, 16 Nov 2017 21:22:57 +0000 (16:22 -0500)]
Make PL/Python handle domain-type conversions correctly.

Fix PL/Python so that it can handle domains over composite, and so that
it enforces domain constraints correctly in other cases that were not
always done properly before.  Notably, it didn't do arrays of domains
right (oversight in commit c12d570fa), and it failed to enforce domain
constraints when returning a composite type containing a domain field,
and if a transform function is being used for a domain's base type then
it failed to enforce domain constraints on the result.  Also, in many
places it missed checking domain constraints on null values, because
the plpy_typeio code simply wasn't called for Py_None.

Rather than try to band-aid these problems, I made a significant
refactoring of the plpy_typeio logic.  The existing design of recursing
for array and composite members is extended to also treat domains as
containers requiring recursion, and the APIs for the module are cleaned
up and simplified.

The patch also modifies plpy_typeio to rely on the typcache more than
it did before (which was pretty much not at all).  This reduces the
need for repetitive lookups, and lets us get rid of an ad-hoc scheme
for detecting changes in composite types.  I added a couple of small
features to typcache to help with that.

Although some of this is fixing bugs that long predate v11, I don't
think we should risk a back-patch: it's a significant amount of code
churn, and there've been no complaints from the field about the bugs.

Tom Lane, reviewed by Anthony Bykov

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

6 years agoRemove redundant line from Makefile.
Robert Haas [Thu, 16 Nov 2017 20:30:56 +0000 (15:30 -0500)]
Remove redundant line from Makefile.

Masahiko Sawada, reviewed by Michael Paquier

Discussion: http://postgr.es/m/CAD21AoDFes_Mgye-1K89rmTgeU3RxYF3zgTjzCJVq2KzzcpC4A@mail.gmail.com

6 years agoFix broken cleanup interlock for GIN pending list.
Robert Haas [Thu, 16 Nov 2017 19:19:27 +0000 (14:19 -0500)]
Fix broken cleanup interlock for GIN pending list.

The pending list must (for correctness) always be cleaned up by vacuum, and
should (for the avoidance of surprising behavior) always be cleaned up
by an explicit call to gin_clean_pending_list, but cleanup is optional
when inserting.  The old logic got this backward: cleanup was forced
if (stats == NULL), but that's going to be *false* when vacuuming and
*true* for inserts.

Masahiko Sawada, reviewed by me.

Discussion: http://postgr.es/m/CAD21AoBLUSyiYKnTYtSAbC+F=XDjiaBrOUEGK+zUXdQ8owfPKw@mail.gmail.com

6 years agoFix typo in comment.
Robert Haas [Thu, 16 Nov 2017 19:16:45 +0000 (14:16 -0500)]
Fix typo in comment.

Etsuro Fujita

Discussion: http://postgr.es/m/5A0D7C3D.80803@lab.ntt.co.jp

6 years agoUpdate postgresql.conf.sample to match pg_settings classificaitons.
Robert Haas [Thu, 16 Nov 2017 17:57:17 +0000 (12:57 -0500)]
Update postgresql.conf.sample to match pg_settings classificaitons.

A handful of settings, most notably shared_preload_libraries, were
just plain the wrong place compared to their assigned config_group
value in guc.c (and thus pg_settings).  In other cases the names of
the sections in postgresql.conf.sample were mildly different from
the corresponding entries in config_group_names[].  Make it all
consistent.

Adrián Escoms, reviewed by me.

Discussion: http://postgr.es/m/CACksPC2veEmFRYqwYepWYO9U7aFhAx6sYq+WqjTyHw7uV=E=pw@mail.gmail.com

6 years agoPass InitPlan values to workers via Gather (Merge).
Robert Haas [Thu, 16 Nov 2017 17:06:14 +0000 (12:06 -0500)]
Pass InitPlan values to workers via Gather (Merge).

If a PARAM_EXEC parameter is used below a Gather (Merge) but the InitPlan
that computes it is attached to or above the Gather (Merge), force the
value to be computed before starting parallelism and pass it down to all
workers.  This allows us to use parallelism in cases where it previously
would have had to be rejected as unsafe.  We do - in this case - lose the
optimization that the value is only computed if it's actually used.  An
alternative strategy would be to have the first worker that needs the value
compute it, but one downside of that approach is that we'd then need to
select a parallel-safe path to compute the parameter value; it couldn't for
example contain a Gather (Merge) node.  At some point in the future, we
might want to consider both approaches.

Independent of that consideration, there is a great deal more work that
could be done to make more kinds of PARAM_EXEC parameters parallel-safe.
This infrastructure could be used to allow a Gather (Merge) on the inner
side of a nested loop (although that's not a very appealing plan) and
cases where the InitPlan is attached below the Gather (Merge) could be
addressed as well using various techniques.  But this is a good start.

Amit Kapila, reviewed and revised by me.  Reviewing and testing from
Kuntal Ghosh, Haribabu Kommi, and Tushar Ahuja.

Discussion: http://postgr.es/m/CAA4eK1LV0Y1AUV4cUCdC+sYOx0Z0-8NAJ2Pd9=UKsbQ5Sr7+JQ@mail.gmail.com

6 years agoDefine _WINSOCK_DEPRECATED_NO_WARNINGS in all MSVC builds.
Tom Lane [Thu, 16 Nov 2017 17:03:04 +0000 (12:03 -0500)]
Define _WINSOCK_DEPRECATED_NO_WARNINGS in all MSVC builds.

Commit 0fb54de9a thought that this was only needed in VS2015 and later,
but buildfarm member woodlouse shows that at least VS2013 whines as
well.  Let's just define it regardless of MSVC version; it should be
harmless enough in older releases.

Also, in the wake of ed9b3606d, it seems better to put it in win32_port.h
where <winsock2.h> is included.

Since this is only suppressing a pedantic compiler warning, I don't
feel a need for a back-patch.

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

6 years agoBack out the session_start and session_end hooks feature.
Andrew Dunstan [Thu, 16 Nov 2017 16:35:02 +0000 (11:35 -0500)]
Back out the session_start and session_end hooks feature.

It's become apparent during testing that there are problems with at
least the testing regime. I don't think we should have it without a
working test regime, and the difficulties might indicate implementation
problems anyway, so I'm backing out the whole thing until that's sorted
out.

This reverts commits 7459484 9989f92 cd8ce3a

6 years agoFix bogus logic for checking data dirs' versions within pg_upgrade.
Tom Lane [Thu, 16 Nov 2017 16:16:53 +0000 (11:16 -0500)]
Fix bogus logic for checking data dirs' versions within pg_upgrade.

Commit 9be95ef15 failed to cure all of the redundancy here: we were
actually calling get_major_server_version() three times for each
of the old and new data directories.  While that's not enormously
expensive, it's still sloppy.

A. Akenteva

Discussion: https://postgr.es/m/f9266a85d918a3cf3a386b5148aee666@postgrespro.ru

6 years agoFurther refactoring of c.h and nearby files.
Tom Lane [Thu, 16 Nov 2017 15:36:18 +0000 (10:36 -0500)]
Further refactoring of c.h and nearby files.

This continues the work of commit 91aec93e6 by getting rid of a lot of
Windows-specific funny business in "section 0".  Instead of including
pg_config_os.h in different places depending on platform, let's
standardize on putting it before the system headers, and in consequence
reduce win32.h to just what has to appear before the system headers or
the body of c.h (the latter category seems to include only PGDLLIMPORT
and PGDLLEXPORT).  The rest of what was in win32.h is moved to a new
sub-include of port.h, win32_port.h.  Some of what was in port.h seems
to better belong there too.

It's possible that I missed some declaration ordering dependency that
needs to be preserved, but hopefully the buildfarm will find that
out in short order.

Unlike the previous commit, no back-patch, since this is just cleanup
not a prerequisite for a bug fix.

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

6 years agoRefactor routine to test connection to SSL server
Peter Eisentraut [Thu, 16 Nov 2017 13:41:40 +0000 (08:41 -0500)]
Refactor routine to test connection to SSL server

Move the sub-routines wrappers to check if a connection to a server is
fine or not into the test main module. This is useful for other tests
willing to check connectivity into a server.

Author: Michael Paquier <michael@paquier.xyz>

6 years agoDisable installcheck tests for test_session_hooks
Andrew Dunstan [Wed, 15 Nov 2017 22:49:04 +0000 (17:49 -0500)]
Disable installcheck tests for test_session_hooks

The module requires a preloaded library and the defect can't be cured by
a LOAD instruction in the test script. To achieve this we override the
installcheck target in the module's Makefile, and exclude ithe module in
vcregress.pl.

Along the way, revert commit 9989f92aabd.

6 years agoDisable test_session_hooks test module until buildfarm issues are sorted out
Andrew Dunstan [Wed, 15 Nov 2017 18:32:29 +0000 (13:32 -0500)]
Disable test_session_hooks test module until buildfarm issues are sorted out

6 years agoRemove TRUE and FALSE
Peter Eisentraut [Wed, 16 Aug 2017 04:22:32 +0000 (00:22 -0400)]
Remove TRUE and FALSE

Code should be using true and false.  Existing code can be changed to
those in a backward compatible way.

The definitions in the ecpg header files are left around to avoid
upsetting those users unnecessarily.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoCentralize executor-related partitioning code.
Robert Haas [Wed, 15 Nov 2017 15:23:28 +0000 (10:23 -0500)]
Centralize executor-related partitioning code.

Some code is moved from partition.c, which has grown very quickly lately;
splitting the executor parts out might help to keep it from getting
totally out of control.  Other code is moved from execMain.c.  All is
moved to a new file execPartition.c.  get_partition_for_tuple now has
a new interface that more clearly separates executor concerns from
generic concerns.

Amit Langote.  A slight comment tweak by me.

Discussion: http://postgr.es/m/1f0985f8-3b61-8bc4-4350-baa6d804cb6d@lab.ntt.co.jp

6 years agoAdd hooks for session start and session end
Andrew Dunstan [Wed, 15 Nov 2017 15:16:34 +0000 (10:16 -0500)]
Add hooks for session start and session end

These hooks can be used in loadable modules. A simple test module is
included.

Discussion:  https://postgr.es/m/20170720204733.40f2b7eb.nagata@sraoss.co.jp

Fabrízio de Royes Mello  and Yugo Nagata
Reviewed by Michael Paquier and Aleksandr Parfenov

6 years agoFix typo.
Robert Haas [Wed, 15 Nov 2017 13:37:32 +0000 (08:37 -0500)]
Fix typo.

Jesper Pedersen

Discussion: http://postgr.es/m/000f92d6-f623-95a5-b341-46e2c0495cea@redhat.com

6 years agoAdd parallel_leader_participation GUC.
Robert Haas [Wed, 15 Nov 2017 13:17:29 +0000 (08:17 -0500)]
Add parallel_leader_participation GUC.

Sometimes, for testing, it's useful to have the leader do nothing but
read tuples from workers; and it's possible that could work out better
even in production.

Thomas Munro, reviewed by Amit Kapila and by me.  A few final tweaks
by me.

Discussion: http://postgr.es/m/CAEepm=2U++Lp3bNTv2Bv_kkr5NE2pOyHhxU=G0YTa4ZhSYhHiw@mail.gmail.com

6 years agoPrevent int128 from requiring more than MAXALIGN alignment.
Tom Lane [Tue, 14 Nov 2017 20:03:55 +0000 (15:03 -0500)]
Prevent int128 from requiring more than MAXALIGN alignment.

Our initial work with int128 neglected alignment considerations, an
oversight that came back to bite us in bug #14897 from Vincent Lachenal.
It is unsurprising that int128 might have a 16-byte alignment requirement;
what's slightly more surprising is that even notoriously lax Intel chips
sometimes enforce that.

Raising MAXALIGN seems out of the question: the costs in wasted disk and
memory space would be significant, and there would also be an on-disk
compatibility break.  Nor does it seem very practical to try to allow some
data structures to have more-than-MAXALIGN alignment requirement, as we'd
have to push knowledge of that throughout various code that copies data
structures around.

The only way out of the box is to make type int128 conform to the system's
alignment assumptions.  Fortunately, gcc supports that via its
__attribute__(aligned()) pragma; and since we don't currently support
int128 on non-gcc-workalike compilers, we shouldn't be losing any platform
support this way.

Although we could have just done pg_attribute_aligned(MAXIMUM_ALIGNOF) and
called it a day, I did a little bit of extra work to make the code more
portable than that: it will also support int128 on compilers without
__attribute__(aligned()), if the native alignment of their 128-bit-int
type is no more than that of int64.

Add a regression test case that exercises the one known instance of the
problem, in parallel aggregation over a bigint column.

This will need to be back-patched, along with the preparatory commit
91aec93e6.  But let's see what the buildfarm makes of it first.

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

6 years agoRearrange c.h to create a "compiler characteristics" section.
Tom Lane [Tue, 14 Nov 2017 18:46:54 +0000 (13:46 -0500)]
Rearrange c.h to create a "compiler characteristics" section.

Generalize section 1 to handle stuff that is principally about the
compiler (not libraries), such as attributes, and collect stuff there
that had been dropped into various other parts of c.h.  Also, push
all the gettext macros into section 8, so that section 0 is really
just inclusions rather than inclusions and random other stuff.

The primary goal here is to get pg_attribute_aligned() defined before
section 3, so that we can use it with int128.  But this seems like good
cleanup anyway.

This patch just moves macro definitions around, and shouldn't result
in any changes in generated code.  But I'll push it out separately
to see if the buildfarm agrees.

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

6 years agoDocument changes in large-object privilege checking.
Tom Lane [Tue, 14 Nov 2017 17:33:10 +0000 (12:33 -0500)]
Document changes in large-object privilege checking.

Commit 5ecc0d738 removed the hard-wired superuser checks in lo_import
and lo_export in favor of protecting them with SQL permissions, but
failed to adjust the documentation to match.  Fix that, and add a
<caution> paragraph pointing out the nontrivial security hazards
involved with actually granting such permissions.  (It's still better
than ALLOW_DANGEROUS_LO_FUNCTIONS, though.)

Also, commit ae20b23a9 caused large object read/write privilege to
be checked during lo_open() rather than in the actual read or write
calls.  Document that.

Discussion: https://postgr.es/m/CAB7nPqRHmNOYbETnc_2EjsuzSM00Z+BWKv9sy6tnvSd5gWT_JA@mail.gmail.com

6 years agoSimplify index_[constraint_]create API
Alvaro Herrera [Tue, 14 Nov 2017 14:19:05 +0000 (15:19 +0100)]
Simplify index_[constraint_]create API

Instead of passing large swaths of boolean arguments, define some flags
that can be used in a bitmask.  This makes it easier not only to figure
out what each call site is doing, but also to add some new flags.

The flags are split in two -- one set for index_create directly and
another for constraints.  index_create() itself receives both, and then
passes down the latter to index_constraint_create(), which can also be
called standalone.

Discussion: https://postgr.es/m/20171023151251.j75uoe27gajdjmlm@alvherre.pgsql
Reviewed-by: Simon Riggs
6 years agoAllow running just selected steps of pgbench's initialization sequence.
Tom Lane [Mon, 13 Nov 2017 21:40:03 +0000 (16:40 -0500)]
Allow running just selected steps of pgbench's initialization sequence.

This feature caters to specialized use-cases such as running the normal
pgbench scenario with nonstandard indexes, or inserting other actions
between steps of the initialization sequence.  The normal sequence of
initialization actions is broken down into half a dozen steps which can
be executed in a user-specified order, to the extent to which that's
sensible.  The actions themselves aren't changed, except to make them
more robust against nonstandard uses:

* all four tables are now dropped in one DROP command, to reduce
assumptions about what foreign key relationships exist;

* all four tables are now truncated at the start of the data load
step, for consistency;

* the foreign key creation commands now specify constraint names, to
prevent accidentally creating duplicate constraints by executing the
'f' step twice.

Make some cosmetic adjustments in the messages emitted by pgbench
so that it's clear which steps are getting run, and so that the
messages agree with the documented names of the steps.

In passing, fix failure to enforce that the -v option is used only
in benchmarking mode.

Masahiko Sawada, reviewed by Fabien Coelho, editorialized a bit by me

Discussion: https://postgr.es/m/CAD21AoCsz0ZzfCFcxYZ+PUdpkDd5VsCSG0Pre_-K1EgokCDFYA@mail.gmail.com

6 years agoPush target list evaluation through Gather Merge.
Robert Haas [Mon, 13 Nov 2017 21:33:56 +0000 (16:33 -0500)]
Push target list evaluation through Gather Merge.

We already do this for Gather, but it got overlooked for Gather Merge.

Amit Kapila, with review and minor revisions by Rushabh Lathia
and by me.

Discussion: http://postgr.es/m/CAA4eK1KUC5Uyu7qaifxrjpHxbSeoQh3yzwN3bThnJsmJcZ-qtA@mail.gmail.com

6 years agoTrack in the plan the types associated with PARAM_EXEC parameters.
Robert Haas [Mon, 13 Nov 2017 20:24:12 +0000 (15:24 -0500)]
Track in the plan the types associated with PARAM_EXEC parameters.

Up until now, we only tracked the number of parameters, which was
sufficient to allocate an array of Datums of the appropriate size,
but not sufficient to, for example, know how to serialize a Datum
stored in one of those slots.  An upcoming patch wants to do that,
so add this tracking to make it possible.

Patch by me, reviewed by Tom Lane and Amit Kapila.

Discussion: http://postgr.es/m/CA+TgmoYqpxDKn8koHdW8BEKk8FMUL0=e8m2Qe=M+r0UBjr3tuQ@mail.gmail.com

6 years agoMention CREATE/DROP STATISTICS in event triggers docs
Alvaro Herrera [Mon, 13 Nov 2017 18:26:35 +0000 (19:26 +0100)]
Mention CREATE/DROP STATISTICS in event triggers docs

The new commands are reported by event triggers, but they weren't
documented as such.  Repair.

Author: David Rowley
Discussion: https://postgr.es/m/CAKJS1f-t-NE=AThB3zu1mKhdrm8PCb=++3e7x=Lf343xcrFHxQ@mail.gmail.com

6 years agoFix typo
Stephen Frost [Mon, 13 Nov 2017 14:40:30 +0000 (09:40 -0500)]
Fix typo

Determinisitcally -> Deterministically

Author: Michael Paquier <michael.paquier@gmail.com>
Discussion: https://postgr.es/m/CAB7nPqSauJ9gUMzj1aiXQVxqEkyko+WZ+wUac8_hB_M_bO6U_A@mail.gmail.com

6 years agoMSVC: Rebuild spiexceptions.h when out of date.
Noah Misch [Mon, 13 Nov 2017 02:43:32 +0000 (18:43 -0800)]
MSVC: Rebuild spiexceptions.h when out of date.

Also, add a warning to catch future instances of naming a nonexistent
file as a prerequisite.  Back-patch to 9.3 (all supported versions).

6 years agoInstall Windows crash dump handler before all else.
Noah Misch [Sun, 12 Nov 2017 22:31:00 +0000 (14:31 -0800)]
Install Windows crash dump handler before all else.

Apart from calling write_stderr() on failure, the handler depends on no
PostgreSQL facilities.  We have experienced crashes before reaching the
former call site.  Given such an early crash, this change cannot hurt
and may produce a helpful dump.  Absent an early crash, this change has
no effect.  Back-patch to 9.3 (all supported versions).

Takayuki Tsunakawa

Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F80CD13@G01JPEXMBYT05

6 years agoDon't call pgwin32_message_to_UTF16() without CurrentMemoryContext.
Noah Misch [Sun, 12 Nov 2017 21:03:15 +0000 (13:03 -0800)]
Don't call pgwin32_message_to_UTF16() without CurrentMemoryContext.

PostgreSQL running as a Windows service crashed upon calling
write_stderr() before MemoryContextInit().  This fix completes work
started in 5735efee15540765315aa8c1a230575e756037f7.  Messages this
early contain only ASCII bytes; if we removed the CurrentMemoryContext
requirement, the ensuing conversions would have no effect.  Back-patch
to 9.3 (all supported versions).

Takayuki Tsunakawa, reviewed by Michael Paquier.

Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F80CC73@G01JPEXMBYT05

6 years agoAdd post-2010 ecpg tests to checktcp.
Noah Misch [Sat, 11 Nov 2017 22:35:22 +0000 (14:35 -0800)]
Add post-2010 ecpg tests to checktcp.

This suite had been a proper superset of the regular ecpg test suite,
but the three newest tests didn't reach it.  To make this less likely to
recur, delete the extra schedule file and pass the TCP-specific test on
the command line.  Back-patch to 9.3 (all supported versions).

6 years agoMake connect/test1 independent of localhost IPv6.
Noah Misch [Sat, 11 Nov 2017 22:33:02 +0000 (14:33 -0800)]
Make connect/test1 independent of localhost IPv6.

Since commit 868898739a8da9ab74c105b8349b7b5c711f265a, it has assumed
"localhost" resolves to both ::1 and 127.0.0.1.  We gain nothing from
that assumption, and it does not hold in a default installation of Red
Hat Enterprise Linux 5.  Back-patch to 9.3 (all supported versions).

6 years agoFix previous commit's test, for non-UTF8 databases with non-XML builds.
Noah Misch [Sat, 11 Nov 2017 21:07:46 +0000 (13:07 -0800)]
Fix previous commit's test, for non-UTF8 databases with non-XML builds.

To ensure stable output, catch one more configuration-specific error.
Back-patch to 9.3, like the commit that added the test.

6 years agoIgnore XML declaration in xpath_internal(), for UTF8 databases.
Noah Misch [Sat, 11 Nov 2017 19:10:53 +0000 (11:10 -0800)]
Ignore XML declaration in xpath_internal(), for UTF8 databases.

When a value contained an XML declaration naming some other encoding,
this function interpreted UTF8 bytes as the named encoding, yielding
mojibake.  xml_parse() already has similar logic.  This would be
necessary but not sufficient for non-UTF8 databases, so preserve
behavior there until the xpath facility can support such databases
comprehensively.  Back-patch to 9.3 (all supported versions).

Pavel Stehule and Noah Misch

Discussion: https://postgr.es/m/CAFj8pRC-dM=tT=QkGi+Achkm+gwPmjyOayGuUfXVumCxkDgYWg@mail.gmail.com

6 years agoAccount for the effect of lossy pages when costing bitmap scans.
Robert Haas [Fri, 10 Nov 2017 21:50:50 +0000 (16:50 -0500)]
Account for the effect of lossy pages when costing bitmap scans.

Dilip Kumar, reviewed by Alexander Kumenkov, Amul Sul, and me.
Some final adjustments by me.

Discussion: http://postgr.es/m/CAFiTN-sYtqUOXQ4SpuhTv0Z9gD0si3YxZGv_PQAAMX8qbOotcg@mail.gmail.com

6 years agoFix some null pointer dereferences in LDAP auth code
Peter Eisentraut [Fri, 10 Nov 2017 19:21:32 +0000 (14:21 -0500)]
Fix some null pointer dereferences in LDAP auth code

An LDAP URL without a host name such as "ldap://" or without a base DN
such as "ldap://localhost" would cause a crash when reading pg_hba.conf.

If no binddn is configured, an error message might end up trying to print a
null pointer, which could crash on some platforms.

Author: Thomas Munro <thomas.munro@enterprisedb.com>
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoAdd some const decorations to prototypes
Peter Eisentraut [Tue, 31 Oct 2017 14:34:31 +0000 (10:34 -0400)]
Add some const decorations to prototypes

Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>
6 years agoTighten test in contrib/bloom/t/001_wal.pl.
Tom Lane [Fri, 10 Nov 2017 17:30:01 +0000 (12:30 -0500)]
Tighten test in contrib/bloom/t/001_wal.pl.

Make bloom WAL test compare psql output text, not just result codes;
this was evidently the intent all along, but it was mis-coded.
In passing, make sure we will notice any failure in setup steps.

Alexander Korotkov, reviewed by Michael Paquier and Masahiko Sawada

Discussion: https://postgr.es/m/CAPpHfdtohPdQ9rc5mdWjxq+3VsBNw534KV_5O65dTQrSdVJNgw@mail.gmail.com

6 years agoFix incorrect comment.
Robert Haas [Fri, 10 Nov 2017 15:55:09 +0000 (10:55 -0500)]
Fix incorrect comment.

Etsuro Fujita

Discussion: http://postgr.es/m/5A05728E.4050009@lab.ntt.co.jp

6 years agoAdd -wnet to SP invocations
Peter Eisentraut [Thu, 9 Nov 2017 22:06:32 +0000 (17:06 -0500)]
Add -wnet to SP invocations

This causes a warning when accidentally backpatching an XML-style
empty-element tag like <xref linkend="abc"/>.

6 years agoAdd hash partitioning.
Robert Haas [Thu, 9 Nov 2017 23:07:25 +0000 (18:07 -0500)]
Add hash partitioning.

Hash partitioning is useful when you want to partition a growing data
set evenly.  This can be useful to keep table sizes reasonable, which
makes maintenance operations such as VACUUM faster, or to enable
partition-wise join.

At present, we still depend on constraint exclusion for partitioning
pruning, and the shape of the partition constraints for hash
partitioning is such that that doesn't work.  Work is underway to fix
that, which should both improve performance and make partitioning
pruning work with hash partitioning.

Amul Sul, reviewed and tested by Dilip Kumar, Ashutosh Bapat, Yugo
Nagata, Rajkumar Raghuwanshi, Jesper Pedersen, and by me.  A few
final tweaks also by me.

Discussion: http://postgr.es/m/CAAJ_b96fhpJAP=ALbETmeLk1Uni_GFZD938zgenhF49qgDTjaQ@mail.gmail.com

6 years agoRemove junk left from DSSSL to XSL conversion
Peter Eisentraut [Thu, 9 Nov 2017 22:00:53 +0000 (17:00 -0500)]
Remove junk left from DSSSL to XSL conversion

6 years agoRefactor permissions checks for large objects.
Tom Lane [Thu, 9 Nov 2017 17:56:07 +0000 (12:56 -0500)]
Refactor permissions checks for large objects.

Up to now, ACL checks for large objects happened at the level of
the SQL-callable functions, which led to CVE-2017-7548 because of a
missing check.  Push them down to be enforced in inv_api.c as much
as possible, in hopes of preventing future bugs.  This does have the
effect of moving read and write permission errors to happen at lo_open
time not loread or lowrite time, but that seems acceptable.

Michael Paquier and Tom Lane

Discussion: https://postgr.es/m/CAB7nPqRHmNOYbETnc_2EjsuzSM00Z+BWKv9sy6tnvSd5gWT_JA@mail.gmail.com

6 years agoRestrict lo_import()/lo_export() via SQL permissions not hard-wired checks.
Tom Lane [Thu, 9 Nov 2017 17:36:58 +0000 (12:36 -0500)]
Restrict lo_import()/lo_export() via SQL permissions not hard-wired checks.

While it's generally unwise to give permissions on these functions to
anyone but a superuser, we've been moving away from hard-wired permission
checks inside functions in favor of using the SQL permission system to
control access.  Bring lo_import() and lo_export() into compliance with
that approach.

In particular, this removes the manual configuration option
ALLOW_DANGEROUS_LO_FUNCTIONS.  That dates back to 1999 (commit 4cd4a54c8);
it's unlikely anyone has used it in many years.  Moreover, if you really
want such behavior, now you can get it with GRANT ... TO PUBLIC instead.

Michael Paquier

Discussion: https://postgr.es/m/CAB7nPqRHmNOYbETnc_2EjsuzSM00Z+BWKv9sy6tnvSd5gWT_JA@mail.gmail.com

6 years agoFix typo in ALTER SYSTEM output.
Tom Lane [Thu, 9 Nov 2017 16:57:20 +0000 (11:57 -0500)]
Fix typo in ALTER SYSTEM output.

The header comment written into postgresql.auto.conf by ALTER SYSTEM
should match what initdb put there originally.

Feike Steenbergen

Discussion: https://postgr.es/m/CAK_s-G0KcKdO=0hqZkwb3s+tqZuuHwWqmF5BDsmoO9FtX75r0g@mail.gmail.com

6 years agoFix bogus logic for checking executables' versions within pg_upgrade.
Tom Lane [Thu, 9 Nov 2017 16:30:30 +0000 (11:30 -0500)]
Fix bogus logic for checking executables' versions within pg_upgrade.

Somebody messed up a refactoring here.  As it stood, we'd check pg_ctl's
--version output twice for each cluster.  Worse, the first check for the
new cluster's version happened before we'd done any validate_exec checks
there, breaking the check ordering the code intended.

A. Akenteva

Discussion: https://postgr.es/m/f9266a85d918a3cf3a386b5148aee666@postgrespro.ru

6 years agoRevert "Allow --with-bonjour to work with non-macOS implementations of Bonjour."
Tom Lane [Thu, 9 Nov 2017 16:00:36 +0000 (11:00 -0500)]
Revert "Allow --with-bonjour to work with non-macOS implementations of Bonjour."

Upon further review, our Bonjour code doesn't actually work with the
Avahi not-too-compatible compatibility library.  While you can get it
to work on non-macOS platforms if you link to Apple's own mDNSResponder
code, there don't seem to be many people who care about that.  Leaving in
the AC_SEARCH_LIBS call seems more likely to encourage people to build
broken configurations than to do anything very useful.

Hence, remove the AC_SEARCH_LIBS call and put in a warning comment instead.

Discussion: https://postgr.es/m/2D8331C5-D64F-44C1-8717-63EDC6EAF7EB@brightforge.com

6 years agoAllow --with-bonjour to work with non-macOS implementations of Bonjour.
Tom Lane [Wed, 8 Nov 2017 22:47:14 +0000 (17:47 -0500)]
Allow --with-bonjour to work with non-macOS implementations of Bonjour.

On macOS the relevant functions require no special library, but elsewhere
we need to pull in libdns_sd.

Back-patch to supported branches.  No docs change since the docs do not
suggest that this is a Mac-only feature.

Luke Lonergan

Discussion: https://postgr.es/m/2D8331C5-D64F-44C1-8717-63EDC6EAF7EB@brightforge.com

6 years agoDoc: fix erroneous example.
Tom Lane [Wed, 8 Nov 2017 22:20:53 +0000 (17:20 -0500)]
Doc: fix erroneous example.

The grammar requires these options to appear the other way 'round.

jotpe@posteo.de

Discussion: https://postgr.es/m/78933bd0-45ce-690e-b832-a328dd1a5567@posteo.de

6 years agoFix two violations of the ResourceOwnerEnlarge/Remember protocol.
Tom Lane [Wed, 8 Nov 2017 21:50:12 +0000 (16:50 -0500)]
Fix two violations of the ResourceOwnerEnlarge/Remember protocol.

The point of having separate ResourceOwnerEnlargeFoo and
ResourceOwnerRememberFoo functions is so that resource allocation
can happen in between.  Doing it in some other order is just wrong.

OpenTemporaryFile() did open(), enlarge, remember, which would leak the
open file if the enlarge step ran out of memory.  Because fd.c has its own
layer of resource-remembering, the consequences look like they'd be limited
to an intratransaction FD leak, but it's still not good.

IncrBufferRefCount() did enlarge, remember, incr-refcount, which would blow
up if the incr-refcount step ever failed.  It was safe enough when written,
but since the introduction of PrivateRefCountHash, I think the assumption
that no error could happen there is pretty shaky.

The odds of real problems from either bug are probably small, but still,
back-patch to supported branches.

Thomas Munro and Tom Lane, per a comment from Andres Freund

6 years agoChange TRUE/FALSE to true/false
Peter Eisentraut [Wed, 16 Aug 2017 04:22:32 +0000 (00:22 -0400)]
Change TRUE/FALSE to true/false

The lower case spellings are C and C++ standard and are used in most
parts of the PostgreSQL sources.  The upper case spellings are only used
in some files/modules.  So standardize on the standard spellings.

The APIs for ICU, Perl, and Windows define their own TRUE and FALSE, so
those are left as is when using those APIs.

In code comments, we use the lower-case spelling for the C concepts and
keep the upper-case spelling for the SQL concepts.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoPut markup in the right place
Peter Eisentraut [Wed, 8 Nov 2017 15:57:27 +0000 (10:57 -0500)]
Put markup in the right place

6 years agoExpand empty end tag
Peter Eisentraut [Wed, 8 Nov 2017 02:14:41 +0000 (21:14 -0500)]
Expand empty end tag

6 years agoFix typo in comment.
Robert Haas [Tue, 7 Nov 2017 21:34:48 +0000 (16:34 -0500)]
Fix typo in comment.

Masahiko Sawada

Discussion: http://postgr.es/m/CAD21AoDrf5AOpZ-mX-j6O=zFNFfKaTdHkv3o1X2eSs2nBXALug@mail.gmail.com

6 years agoFix unportable spelling of int64 constant.
Tom Lane [Tue, 7 Nov 2017 18:54:36 +0000 (13:54 -0500)]
Fix unportable spelling of int64 constant.

Per buildfarm member pademelon.

6 years agoFix unportable usage of <ctype.h> functions.
Tom Lane [Tue, 7 Nov 2017 18:49:36 +0000 (13:49 -0500)]
Fix unportable usage of <ctype.h> functions.

isdigit(), isspace(), etc are likely to give surprising results if passed a
signed char.  We should always cast the argument to unsigned char to avoid
that.  Error in commit 63d6b97fd, found by buildfarm member gaur.
Back-patch to 9.3, like that commit.

6 years agoRemove secondary checkpoint
Simon Riggs [Tue, 7 Nov 2017 17:56:30 +0000 (12:56 -0500)]
Remove secondary checkpoint

Previously server reserved WAL for last two checkpoints,
which used too much disk space for small servers.

Bumps PG_CONTROL_VERSION

Author: Simon Riggs <simon@2ndQuadrant.com>
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoExclude pg_internal.init from BASE_BACKUP
Simon Riggs [Tue, 7 Nov 2017 17:28:35 +0000 (12:28 -0500)]
Exclude pg_internal.init from BASE_BACKUP

Add docs to explain this for other backup mechanisms

Author: David Steele <david@pgmasters.net>
Reviewed-by: Petr Jelinek <petr.jelinek@2ndQuadrant.com> et al
6 years agoFix version numbering foulups exposed by 10.1.
Tom Lane [Tue, 7 Nov 2017 00:46:52 +0000 (19:46 -0500)]
Fix version numbering foulups exposed by 10.1.

configure computed PG_VERSION_NUM incorrectly.  (Coulda sworn I tested
that logic back when, but it had an obvious thinko.)

pg_upgrade had not been taught about the new dispensation with just
one part in the major version number.

Both things accidentally failed to fail with 10.0, but with 10.1 we
got the wrong results.

Per buildfarm.

6 years agoLast-minute updates for release notes.
Tom Lane [Mon, 6 Nov 2017 17:02:30 +0000 (12:02 -0500)]
Last-minute updates for release notes.

Security: CVE-2017-12172, CVE-2017-15098, CVE-2017-15099

6 years agoAdd tests for json{b}_populate_recordset() crash case.
Tom Lane [Mon, 6 Nov 2017 15:29:11 +0000 (10:29 -0500)]
Add tests for json{b}_populate_recordset() crash case.

The problem reported as CVE-2017-15098 was already resolved in HEAD by
commit 37a795a60, but let's add the relevant test cases anyway.

Michael Paquier and Tom Lane, per a report from David Rowley.

Security: CVE-2017-15098

6 years agostart-scripts: switch to $PGUSER before opening $PGLOG.
Noah Misch [Mon, 6 Nov 2017 15:11:10 +0000 (07:11 -0800)]
start-scripts: switch to $PGUSER before opening $PGLOG.

By default, $PGUSER has permission to unlink $PGLOG.  If $PGUSER
replaces $PGLOG with a symbolic link, the server will corrupt the
link-targeted file by appending log messages.  Since these scripts open
$PGLOG as root, the attack works regardless of target file ownership.

"make install" does not install these scripts anywhere.  Users having
manually installed them in the past should repeat that process to
acquire this fix.  Most script users have $PGLOG writable to root only,
located in $PGDATA.  Just before updating one of these scripts, such
users should rename $PGLOG to $PGLOG.old.  The script will then recreate
$PGLOG with proper ownership.

Reviewed by Peter Eisentraut.  Reported by Antoine Scemama.

Security: CVE-2017-12172

6 years agoAlways require SELECT permission for ON CONFLICT DO UPDATE.
Dean Rasheed [Mon, 6 Nov 2017 09:19:22 +0000 (09:19 +0000)]
Always require SELECT permission for ON CONFLICT DO UPDATE.

The update path of an INSERT ... ON CONFLICT DO UPDATE requires SELECT
permission on the columns of the arbiter index, but it failed to check
for that in the case of an arbiter specified by constraint name.

In addition, for a table with row level security enabled, it failed to
check updated rows against the table's SELECT policies when the update
path was taken (regardless of how the arbiter index was specified).

Backpatch to 9.5 where ON CONFLICT DO UPDATE and RLS were introduced.

Security: CVE-2017-15099

6 years agoAdd a temp-install prerequisite to "check"-like targets not having one.
Noah Misch [Mon, 6 Nov 2017 02:51:08 +0000 (18:51 -0800)]
Add a temp-install prerequisite to "check"-like targets not having one.

Makefile.global assigns this prerequisite to every target named "check",
but similar targets must mention it explicitly.  Affected targets
failed, tested $PATH binaries, or tested a stale temporary installation.
The src/test/modules examples worked properly when called as "make -C
src/test/modules/$FOO check", but "make -j" allowed the test to start
before the temporary installation was in place.  Back-patch to 9.5,
where commit dcae5faccab64776376d354decda0017c648bb53 introduced the
shared temp-install.

6 years agoRelease notes for 10.1, 9.6.6, 9.5.10, 9.4.15, 9.3.20, 9.2.24.
Tom Lane [Sun, 5 Nov 2017 18:47:56 +0000 (13:47 -0500)]
Release notes for 10.1, 9.6.6, 9.5.10, 9.4.15, 9.3.20, 9.2.24.

In the v10 branch, also back-patch the effects of 1ff01b390 and c29c57890
on these files, to reduce future maintenance issues.  (I'd do it further
back, except that the 9.X branches differ anyway due to xlog-to-wal
link tag renaming.)

6 years agoIgnore CatalogSnapshot when checking COPY FREEZE prerequisites.
Noah Misch [Sun, 5 Nov 2017 17:25:52 +0000 (09:25 -0800)]
Ignore CatalogSnapshot when checking COPY FREEZE prerequisites.

This restores the ability, essentially lost in commit
ffaa44cb559db332baeee7d25dedd74a61974203, to use COPY FREEZE under
REPEATABLE READ isolation.  Back-patch to 9.4, like that commit.

Reviewed by Tom Lane.

Discussion: https://postgr.es/m/CA+TgmoahWDm-7fperBxzU9uZ99LPMUmEpSXLTw9TmrOgzwnORw@mail.gmail.com

6 years agoFix comment
Magnus Hagander [Sun, 5 Nov 2017 16:48:20 +0000 (11:48 -0500)]
Fix comment

Author: Bernd Helmle <mailings@oopsware.de>

6 years agoFirst-draft release notes for 10.1.
Tom Lane [Sat, 4 Nov 2017 22:27:06 +0000 (18:27 -0400)]
First-draft release notes for 10.1.

As usual, the release notes for other branches will be made by cutting
these down, but put them up for community review first.  Note that a
fair percentage of the entries apply only to prior branches because
their issue was already fixed in 10.0.

6 years agodoc: Update text for new recovery_target_lsn setting
Peter Eisentraut [Sat, 4 Nov 2017 18:42:20 +0000 (14:42 -0400)]
doc: Update text for new recovery_target_lsn setting

Reported-by: Tomonari Katsumata <t.katsumata1122@gmail.com>
Author: Michael Paquier <michael.paquier@gmail.com>

6 years agoecpg: Use bool instead of int
Peter Eisentraut [Tue, 12 Sep 2017 00:54:55 +0000 (20:54 -0400)]
ecpg: Use bool instead of int

Use "bool" for Boolean variables, rather than "int", matching backend
change f505edace12655f3491b9c91991731e2b6bf1f0b.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoecpg: Remove useless return values
Peter Eisentraut [Tue, 12 Sep 2017 00:43:05 +0000 (20:43 -0400)]
ecpg: Remove useless return values

Remove useless or inconsistently used return values from functions,
matching backend changes 99bf328237d89e0fd22821a940d4af0506353218 and
791359fe0eae83641f0929159d5861359d395e97.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoFix incorrect use of bool
Peter Eisentraut [Thu, 14 Sep 2017 12:30:03 +0000 (08:30 -0400)]
Fix incorrect use of bool

NSUnLinkModule() doesn't take a bool as second argument but one of set
of specific constants.  The numeric values are the same in this case,
but clean it up while we're cleaning up bool use elsewhere.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
6 years agoAvoid looping through line pointers twice in PageRepairFragmentation().
Tom Lane [Fri, 3 Nov 2017 21:21:59 +0000 (17:21 -0400)]
Avoid looping through line pointers twice in PageRepairFragmentation().

There doesn't seem to be any good reason to do the filling of the
itemidbase[] array separately from the first traversal of the pointers.
It's certainly not a win if there are any line pointers with storage,
and even if there aren't, this change doesn't insert code into the part
of the first loop that will be traversed in that case.  So let's just
merge the two loops.

Yura Sokolov, reviewed by Claudio Freire

Discussion: https://postgr.es/m/e49befcc6f1d7099834c6fdf5c675a60@postgrespro.ru

6 years agoFlag index metapages as standard-format in xlog.c calls.
Tom Lane [Fri, 3 Nov 2017 20:31:32 +0000 (16:31 -0400)]
Flag index metapages as standard-format in xlog.c calls.

btree, hash, and bloom indexes all set up their metapages in standard
format (that is, with pd_lower and pd_upper correctly delimiting the
unused area); but they mostly didn't inform the xlog routines of this.
When calling log_newpage[_buffer], this is bad because it loses the
opportunity to compress unused data out of the WAL record.  When
calling XLogRegisterBuffer, it's not such a performance problem because
all of these call sites also use REGBUF_WILL_INIT, preventing an FPI
image from being written.  But it's still a good idea to provide the
flag when relevant, because that aids WAL consistency checking.

This completes the project of getting all the in-core index AMs to
handle their metapage WAL operations similarly.

Amit Kapila, reviewed by Michael Paquier

Discussion: https://postgr.es/m/0d273805-0e9e-ec1a-cb84-d4da400b8f85@lab.ntt.co.jp

6 years agoFix thinkos in BRIN summarization
Alvaro Herrera [Fri, 3 Nov 2017 19:36:32 +0000 (20:36 +0100)]
Fix thinkos in BRIN summarization

The previous commit contained a thinko that made a single-range
summarization request process from there to end of table.  Fix by
setting the correct end range point.  Per buildfarm.

6 years agodoc: Convert ids to upper case at build time
Peter Eisentraut [Thu, 26 Oct 2017 19:19:56 +0000 (15:19 -0400)]
doc: Convert ids to upper case at build time

This makes the produced HTML anchors upper case, making it backward
compatible with the previous (9.6) build system.

Reported-by: Thomas Kellerer <spam_eater@gmx.net>
6 years agoDon't reset additional columns on subscriber to NULL on UPDATE
Peter Eisentraut [Fri, 3 Nov 2017 15:59:20 +0000 (11:59 -0400)]
Don't reset additional columns on subscriber to NULL on UPDATE

When a publisher table has fewer columns than a subscriber, the update
of a row on the publisher should result in updating of only the columns
in common.  The previous coding mistakenly reset the values of
additional columns on the subscriber to NULL because it failed to skip
updates of columns not found in the attribute map.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>

6 years agoFix BRIN summarization concurrent with extension
Alvaro Herrera [Fri, 3 Nov 2017 16:23:13 +0000 (17:23 +0100)]
Fix BRIN summarization concurrent with extension

If a process is extending a table concurrently with some BRIN
summarization process, it is possible for the latter to miss pages added
by the former because the number of pages is computed ahead of time.

Fix by determining a fresh relation size after inserting the placeholder
tuple: any process that further extends the table concurrently will
update the placeholder tuple, while previous pages will be processed by
the heap scan.

Reported-by: Tomas Vondra
Reviewed-by: Tom Lane
Author: Álvaro Herrera
Discussion: https://postgr.es/m/083d996a-4a8a-0e13-800a-851dd09ad8cc@2ndquadrant.com
Backpatch-to: 9.5
6 years agoImprove error message for incorrect number inputs in libecpg.
Michael Meskes [Fri, 3 Nov 2017 10:14:30 +0000 (11:14 +0100)]
Improve error message for incorrect number inputs in libecpg.

6 years agopgbench: replace run-time string comparisons with an enum identifier.
Tom Lane [Thu, 2 Nov 2017 22:32:14 +0000 (18:32 -0400)]
pgbench: replace run-time string comparisons with an enum identifier.

Minor refactoring that should yield some performance benefit.

Fabien Coelho, reviewed by Aleksandr Parfenov

Discussion: https://postgr.es/m/alpine.DEB.2.20.1709230538130.4999@lancre

6 years agoSet the metapage's pd_lower correctly in brin, gin, and spgist indexes.
Tom Lane [Thu, 2 Nov 2017 21:22:08 +0000 (17:22 -0400)]
Set the metapage's pd_lower correctly in brin, gin, and spgist indexes.

Previously, these index types left the pd_lower field set to the default
SizeOfPageHeaderData, which is really a lie because it ought to point past
whatever space is being used for metadata.  The coding accidentally failed
to fail because we never told xlog.c that the metapage is of standard
format --- but that's not very good, because it impedes WAL consistency
checking, and in some cases prevents compression of full-page images.

To fix, ensure that we set pd_lower correctly, not only when creating a
metapage but whenever we write it out (these apparently redundant steps are
needed to cope with pg_upgrade'd indexes that don't yet contain the right
value).  This allows telling xlog.c that the page is of standard format.

The WAL consistency check mask functions are made to mask only if pd_lower
appears valid, which I think is likely unnecessary complication, since
any metapage appearing in a v11 WAL stream should contain valid pd_lower.
But it doesn't cost much to be paranoid.

Amit Langote, reviewed by Michael Paquier and Amit Kapila

Discussion: https://postgr.es/m/0d273805-0e9e-ec1a-cb84-d4da400b8f85@lab.ntt.co.jp

6 years agoFix float parsing in ecpg INFORMIX mode.
Michael Meskes [Thu, 2 Nov 2017 19:46:34 +0000 (20:46 +0100)]
Fix float parsing in ecpg INFORMIX mode.

6 years agopg_ctl: Improve message
Peter Eisentraut [Thu, 2 Nov 2017 17:27:42 +0000 (13:27 -0400)]
pg_ctl: Improve message

Change message for restarting a server from a directory without a PID
file.  This accounts for the case where a restart happens after an
initdb.  The new message indicates that the start has not completed yet
and might fail.

Author: Jesper Pedersen <jesper.pedersen@redhat.com>

6 years agoSimplify new test suite handling of passwordcheck
Peter Eisentraut [Thu, 2 Nov 2017 16:56:30 +0000 (12:56 -0400)]
Simplify new test suite handling of passwordcheck

This changes the use of a custom configuration file to enforce the value
of preload_shared_libraries to simply load the library during the tests.
This removes the restriction of running installcheck on the tests, and
simplifies its makefile contrary to what has been introduced in af7211e.

Author: Michael Paquier <michael.paquier@gmail.com>

6 years agoFix corner-case errors in brin_doupdate().
Tom Lane [Thu, 2 Nov 2017 16:54:22 +0000 (12:54 -0400)]
Fix corner-case errors in brin_doupdate().

In some cases the BRIN code releases lock on an index page, and later
re-acquires lock and tries to check that the tuple it was working on is
still there.  That check was a couple bricks shy of a load.  It didn't
consider that the page might have turned into a "revmap" page.  (The
samepage code path doesn't call brin_getinsertbuffer(), so it isn't
protected by the checks for revmap status there.)  It also didn't check
whether the tuple offset was now off the end of the linepointer array.
Since commit 24992c6db the latter case is pretty common, but at least
in principle it could have occurred before that.  The net result is
that concurrent updates of a BRIN index could fail with errors like
"invalid index offnum" or "inconsistent range map".

Per report from Tomas Vondra.  Back-patch to 9.5, since this code is
substantially the same in all versions containing BRIN.

Discussion: https://postgr.es/m/10d2b9f9-f427-03b8-8ad9-6af4ecacbee9@2ndquadrant.com

6 years agoRemove wal_keep_segments from default configuration in PostgresNode.pm
Peter Eisentraut [Thu, 2 Nov 2017 16:38:59 +0000 (12:38 -0400)]
Remove wal_keep_segments from default configuration in PostgresNode.pm

This is only used in the pg_rewind tests, so only set it there.  It's
better if other tests run closer to a default configuration.

Author: Michael Paquier <michael.paquier@gmail.com>

6 years agodoc: Clarify pgstattuple privileges information
Peter Eisentraut [Thu, 2 Nov 2017 16:12:23 +0000 (12:12 -0400)]
doc: Clarify pgstattuple privileges information

The description has gotten a bit confusing over time, so rewrite the
paragraph a bit.

Reported-by: Feike Steenbergen <feikesteenbergen@gmail.com>