]> granicus.if.org Git - postgresql/log
postgresql
7 years agoFix regexport.c to behave sanely with lookaround constraints.
Tom Lane [Thu, 13 Apr 2017 21:18:35 +0000 (17:18 -0400)]
Fix regexport.c to behave sanely with lookaround constraints.

regexport.c thought it could just ignore LACON arcs, but the correct
behavior is to treat them as satisfiable while consuming zero input
(rather reminiscently of commit 9f1e642d5).  Otherwise, the emitted
simplified-NFA representation may contain no paths leading from initial
to final state, which unsurprisingly confuses pg_trgm, as seen in
bug #14623 from Jeff Janes.

Since regexport's output representation has no concept of an arc that
consumes zero input, recurse internally to find the next normal arc(s)
after any LACON transitions.  We'd be forced into changing that
representation if a LACON could be the last arc reaching the final
state, but fortunately the regex library never builds NFAs with such
a configuration, so there always is a next normal arc.

Back-patch to 9.3 where this logic was introduced.

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

7 years agodoc: add missing sect1 close tag
Bruce Momjian [Thu, 13 Apr 2017 17:12:58 +0000 (13:12 -0400)]
doc: add missing sect1 close tag

Fixes commit 4f3b87ab780b95c2cc8a591259baefaff4852037

7 years agoImprove the SASL authentication protocol.
Heikki Linnakangas [Thu, 13 Apr 2017 16:34:16 +0000 (19:34 +0300)]
Improve the SASL authentication protocol.

This contains some protocol changes to SASL authentiation (which is new
in v10):

* For future-proofing, in the AuthenticationSASL message that begins SASL
  authentication, provide a list of SASL mechanisms that the server
  supports, for the client to choose from. Currently, it's always just
  SCRAM-SHA-256.

* Add a separate authentication message type for the final server->client
  SASL message, which the client doesn't need to respond to. This makes
  it unambiguous whether the client is supposed to send a response or not.
  The SASL mechanism should know that anyway, but better to be explicit.

Also, in the server, support clients that don't send an Initial Client
response in the first SASLInitialResponse message. The server is supposed
to first send an empty request in that case, to which the client will
respond with the data that usually comes in the Initial Client Response.
libpq uses the Initial Client Response field and doesn't need this, and I
would assume any other sensible implementation to use Initial Client
Response, too, but let's follow the SASL spec.

Improve the documentation on SASL authentication in protocol. Add a
section describing the SASL message flow, and some details on our
SCRAM-SHA-256 implementation.

Document the different kinds of PasswordMessages that the frontend sends
in different phases of SASL authentication, as well as GSS/SSPI
authentication as separate message formats. Even though they're all 'p'
messages, and the exact format depends on the context, describing them as
separate message formats makes the documentation more clear.

Reviewed by Michael Paquier and Álvaro Hernández Tortosa.

Discussion: https://www.postgresql.org/message-id/CAB7nPqS-aFg0iM3AQOJwKDv_0WkAedRjs1W2X8EixSz+sKBXCQ@mail.gmail.com

7 years agoRefactor libpq authentication request processing.
Heikki Linnakangas [Thu, 13 Apr 2017 16:34:14 +0000 (19:34 +0300)]
Refactor libpq authentication request processing.

Move the responsibility of reading the data from the authentication request
message from PQconnectPoll() to pg_fe_sendauth(). This way, PQconnectPoll()
doesn't need to know about all the different authentication request types,
and we don't need the extra fields in the pg_conn struct to pass the data
from PQconnectPoll() to pg_fe_sendauth() anymore.

Reviewed by Michael Paquier.

Discussion: https://www.postgresql.org/message-id/6490b975-5ee1-6280-ac1d-af975b19fb9a%40iki.fi

7 years agoMove bootstrap-time lookup of regproc OIDs into genbki.pl.
Tom Lane [Thu, 13 Apr 2017 16:07:47 +0000 (12:07 -0400)]
Move bootstrap-time lookup of regproc OIDs into genbki.pl.

Formerly, the bootstrap backend looked up the OIDs corresponding to
names in regproc catalog entries using brute-force searches of pg_proc.
It was somewhat remarkable that that worked at all, since it was used
while populating other pretty-fundamental catalogs like pg_operator.
And it was also quite slow, and getting slower as pg_proc gets bigger.

This patch moves the lookup work into genbki.pl, so that the values in
postgres.bki for regproc columns are always numeric OIDs, an option
that regprocin() already supported.  Perl isn't the world's speediest
language, so this about doubles the time needed to run genbki.pl (from
0.3 to 0.6 sec on my machine).  But we only do that at most once per
build.  The time needed to run initdb drops significantly --- on my
machine, initdb --no-sync goes from 1.8 to 1.3 seconds.  So this is
a small net win even for just one initdb per build, and it becomes
quite a nice win for test sequences requiring many initdb runs.

Strip out the now-dead code for brute-force catalog searching in
regprocin.  We'd also cargo-culted similar logic into regoperin
and some (not all) of the other reg*in functions.  That is all
dead code too since we currently have no need to load such values
during bootstrap.  I removed it all, reasoning that if we ever
need such functionality it'd be much better to do it in a similar
way to this patch.

There might be some simplifications possible in the backend now that
regprocin doesn't require doing catalog reads so early in bootstrap.
I've not looked into that, though.

Andreas Karlsson, with some small adjustments by me

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

7 years agopg_dump: Always dump subscriptions NOCONNECT
Peter Eisentraut [Thu, 13 Apr 2017 02:12:30 +0000 (22:12 -0400)]
pg_dump: Always dump subscriptions NOCONNECT

This removes the pg_dump option --no-subscription-connect and makes it
the default.  Dumping a subscription so that it activates right away
when restored is not very useful, because the state of the publication
server is unclear.

Discussion: https://www.postgresql.org/message-id/e4fbfad5-c6ac-fd50-6777-18c84b34eb2f@2ndquadrant.com

7 years agopg_dump: Dump subscriptions by default
Peter Eisentraut [Wed, 12 Apr 2017 02:02:59 +0000 (22:02 -0400)]
pg_dump: Dump subscriptions by default

Dump subscriptions if the current user is a superuser, otherwise write a
warning and skip them.  Remove the pg_dump option
--include-subscriptions.

Discussion: https://www.postgresql.org/message-id/e4fbfad5-c6ac-fd50-6777-18c84b34eb2f@2ndquadrant.com

7 years agoFix XMLTABLE synopsis, add XMLNAMESPACES example
Alvaro Herrera [Thu, 13 Apr 2017 15:08:34 +0000 (12:08 -0300)]
Fix XMLTABLE synopsis, add XMLNAMESPACES example

Add a missing comma in the synopsis after the XMLNAMESPACES clause.
Also, add an example illustrating the use of that clause.

Author: Arjen Nienhuis and Pavel Stěhule

7 years agoCatversion bump forgotten in previous commit
Alvaro Herrera [Thu, 13 Apr 2017 14:54:00 +0000 (11:54 -0300)]
Catversion bump forgotten in previous commit

7 years agoMinor cleanup of backend SCRAM code.
Heikki Linnakangas [Thu, 13 Apr 2017 14:44:15 +0000 (17:44 +0300)]
Minor cleanup of backend SCRAM code.

Free each SASL message after sending it. It's not a lot of wasted memory,
and it's short-lived, but the authentication code in general tries to
pfree() stuff, so let's follow the example.

Adding the pfree() revealed a little bug in build_server_first_message().
It attempts to keeps a copy of the sent message, but it was missing a
pstrdup(), so the pointer started to dangle, after adding the pfree()
into CheckSCRAMAuth().

Reword comments and debug messages slightly, while we're at it.

Reviewed by Michael Paquier.

Discussion: https://www.postgresql.org/message-id/6490b975-5ee1-6280-ac1d-af975b19fb9a@iki.fi

7 years agoRemove pg_stats_ext view
Alvaro Herrera [Thu, 13 Apr 2017 14:35:22 +0000 (11:35 -0300)]
Remove pg_stats_ext view

It was created as equivalent of pg_stats, but since the code underlying
pg_statistic_ext is more convenient than the one for pg_statistic,
pg_stats_ext is no longer useful.

Author: David Rowley
Reviewed-by: Tomas Vondra
Discussion: https://postgr.es/m/CAKJS1f9zAkPUf9nQrqpFBAsrOHvb5eYa2FVNsmCJy1wegcO_TQ@mail.gmail.com

7 years agodocs: update major release instructions
Bruce Momjian [Thu, 13 Apr 2017 14:19:12 +0000 (10:19 -0400)]
docs:  update major release instructions

7 years agogit_changelog: improve comment
Bruce Momjian [Thu, 13 Apr 2017 13:13:43 +0000 (09:13 -0400)]
git_changelog:  improve comment

7 years agoMention pg_index changes also cause relcache invalidation
Simon Riggs [Thu, 13 Apr 2017 09:07:21 +0000 (10:07 +0100)]
Mention pg_index changes also cause relcache invalidation

Amit Langote, additional line by me

7 years agoMove pg_stat_progress_vacuum to the table of Dynamic Statistics Views in doc.
Fujii Masao [Thu, 13 Apr 2017 03:09:14 +0000 (12:09 +0900)]
Move pg_stat_progress_vacuum to the table of Dynamic Statistics Views in doc.

Previously the description about pg_stat_progress_vacuum was in the table
of "Collected Statistics Views" in the doc. But since it repors dynamic
information, i.e., the current progress of VACUUM, its description should be
in the table of "Dynamic Statistics Views".

Back-patch to 9.6 where pg_stat_progress_vacuum was added.

Author: Amit Langote
Discussion: http://postgr.es/m/7ab51b59-8d4d-6193-c60a-b75f222efb12@lab.ntt.co.jp

7 years agoImprove documentations for ALTER PUBLICATION and ALTER SUBSCRIPTION.
Fujii Masao [Thu, 13 Apr 2017 02:29:53 +0000 (11:29 +0900)]
Improve documentations for ALTER PUBLICATION and ALTER SUBSCRIPTION.

Discussion: http://postgr.es/m/CAD21AoC32YgtateNqTFXzTJmHHe6hXs4cpJTND3n-Ts8f-aMqw@mail.gmail.com

7 years agoImprove tab-completion of DDL for publication and subscription.
Fujii Masao [Thu, 13 Apr 2017 02:26:36 +0000 (11:26 +0900)]
Improve tab-completion of DDL for publication and subscription.

Author: Masahiko Sawada
Discussion: http://postgr.es/m/CAD21AoC32YgtateNqTFXzTJmHHe6hXs4cpJTND3n-Ts8f-aMqw@mail.gmail.com

7 years agoSpeed up hash_index regression test.
Tom Lane [Wed, 12 Apr 2017 20:17:53 +0000 (16:17 -0400)]
Speed up hash_index regression test.

Commit f5ab0a14e made this test take substantially longer than it used
to.  With a bit more care, we can get the runtime back down while
achieving the same, or even a bit better, code coverage.

Mithun Cy

Discussion: https://postgr.es/m/CAD__Ouh-qaEb+rD7Uy-4g3xQYOrhPzHs-a_TrFAjiQ5azAW5+w@mail.gmail.com

7 years agoAvoid transferring parallel-unsafe subplans to parallel workers.
Tom Lane [Wed, 12 Apr 2017 20:06:49 +0000 (16:06 -0400)]
Avoid transferring parallel-unsafe subplans to parallel workers.

Commit 5e6d8d2bb allowed parallel workers to execute parallel-safe
subplans, but it transmitted the query's entire list of subplans to
the worker(s).  Since execMain.c blindly does ExecInitNode and later
ExecEndNode on every list element, this resulted in parallel-unsafe plan
nodes nonetheless getting started up and shut down in parallel workers.
That seems mostly harmless as far as core plan node types go (but
maybe not so much for Gather?).  But it resulted in postgres_fdw
opening and then closing extra remote connections, and it's likely
that other non-parallel-safe FDWs or custom scan providers would have
worse reactions.

To fix, just make ExecSerializePlan replace parallel-unsafe subplans
with NULLs in the cut-down plan tree that it transmits to workers.
This relies on ExecInitNode and ExecEndNode to do nothing on NULL
input, but they do anyway.  If anything else is touching the dropped
subplans in a parallel worker, that would be a bug to be fixed.
(This thus provides a strong guarantee that we won't try to do
something with a parallel-unsafe subplan in a worker.)

This is, I think, the last fix directly occasioned by Andreas Seltenreich's
bug report of a few days ago.

Tom Lane and Amit Kapila

Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de

7 years agodoc: Tweak CSS
Peter Eisentraut [Wed, 12 Apr 2017 19:37:03 +0000 (15:37 -0400)]
doc: Tweak CSS

Tweak CSS a bit to match latest similar changes to web site style.  Also
move some CSS out of the HTML to the stylesheet so that the web site
stylesheet can override it.  This should ensure that notes and such are
back to being centered.

7 years agogit_changelog: improve instructions for finding branch commits
Bruce Momjian [Wed, 12 Apr 2017 19:40:30 +0000 (15:40 -0400)]
git_changelog:  improve instructions for finding branch commits

Specifically, use '--summary' with 'git show'.

7 years agoMark finished Plan nodes with parallel_safe flags.
Tom Lane [Wed, 12 Apr 2017 19:13:23 +0000 (15:13 -0400)]
Mark finished Plan nodes with parallel_safe flags.

We'd managed to avoid doing this so far, but it seems pretty obvious
that it would be forced on us some day, and this is much the cleanest
way of approaching the open problem that parallel-unsafe subplans are
being transmitted to parallel workers.  Anyway there's no space cost
due to alignment considerations, and the time cost is pretty minimal
since we're just copying the flag from the corresponding Path node.
(At least in most cases ... some of the klugier spots in createplan.c
have to work a bit harder.)

In principle we could perhaps get rid of SubPlan.parallel_safe,
but I thought it better to keep that in case there are reasons to
consider a SubPlan unsafe even when its child plan is parallel-safe.

This patch doesn't actually do anything with the new flags, but
I thought I'd commit it separately anyway.

Note: although this touches outfuncs/readfuncs, there's no need for
a catversion bump because Plan trees aren't stored on disk.

Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de

7 years agoRemove some tabs in SQL code in C string literals
Peter Eisentraut [Wed, 12 Apr 2017 18:43:01 +0000 (14:43 -0400)]
Remove some tabs in SQL code in C string literals

This is not handled uniformly throughout the code, but at least nearby
code can be consistent.

7 years agoFix pgstattuple's handling of unused hash pages.
Robert Haas [Wed, 12 Apr 2017 15:53:00 +0000 (11:53 -0400)]
Fix pgstattuple's handling of unused hash pages.

Hash indexes can contain both pages which are all-zeroes (i.e.
PageIsNew()) and pages which have been initialized but currently
aren't used.  The latter category can happen either when a page
has been reserved but not yet used or when it is used for a time
and then freed.  pgstattuple was only prepared to deal with the
pages that are actually-zeroes, which it called zero_pages.
Rename the column to unused_pages (extension version 1.5 is
as-yet-unreleased) and make it count both kinds of unused pages.

Along the way, slightly tidy up the way we test for pages of
various types.

Robert Haas and Ashutosh Sharma, reviewed by Amit Kapila

Discussion: http://postgr.es/m/CAE9k0PkTtKFB3YndOyQMjwuHx+-FtUP1ynK8E-nHtetoow3NtQ@mail.gmail.com

7 years agoCode review for c94e6942cefe7d20c5feed856e27f672734b1e2b.
Robert Haas [Wed, 12 Apr 2017 15:13:44 +0000 (11:13 -0400)]
Code review for c94e6942cefe7d20c5feed856e27f672734b1e2b.

validateCheckConstraint() shouldn't try to access the storage for
a partitioned table, because it no longer has any.  Creating a
_RETURN table on a partitioned table shouldn't be allowed, both
because there's no value in it and because trying to do so would
involve a validation scan against its nonexistent storage.

Amit Langote, reviewed by Tom Lane.  Regression test outputs
updated to pass by me.

Discussion: http://postgr.es/m/e5c3cbd3-1551-d6f8-c9e2-51777d632fd2@lab.ntt.co.jp

7 years agoFix reversed check of return value from sync
Magnus Hagander [Wed, 12 Apr 2017 11:43:59 +0000 (13:43 +0200)]
Fix reversed check of return value from sync

While at it also update the comments in walmethods.h to make it less
likely for mistakes like this to appear in the future (thanks to Tom for
improvements to the comments).

And finally, in passing change the return type of walmethod.getlasterror
to being const, also per suggestion from Tom.

7 years agoRemove bogus redefinition of _MSC_VER.
Tom Lane [Tue, 11 Apr 2017 19:32:33 +0000 (15:32 -0400)]
Remove bogus redefinition of _MSC_VER.

Commit a4777f355 was a shade too mechanical: we don't want to override
MSVC's own definition of _MSC_VER, as that breaks tests on its numerical
value.  Per buildfarm.

7 years agoSimplify handling of remote-qual pass-forward in postgres_fdw.
Tom Lane [Tue, 11 Apr 2017 17:53:13 +0000 (13:53 -0400)]
Simplify handling of remote-qual pass-forward in postgres_fdw.

Commit 0bf3ae88a encountered a need to pass the finally chosen remote qual
conditions forward from postgresGetForeignPlan to postgresPlanDirectModify.
It solved that by sticking them into the plan node's fdw_private list,
which in hindsight was a pretty bad idea.  In the first place, there's no
use for those qual trees either in EXPLAIN or execution; indeed they could
never safely be used for any post-planning purposes, because they would not
get processed by setrefs.c.  So they're just dead weight to carry around in
the finished plan tree, plus being an attractive nuisance for somebody who
might get the idea that they could be used that way.  Secondly, because
those qual trees (sometimes) contained RestrictInfos, they created a
plan-transmission hazard for parallel query, which is how come we noticed a
problem.  We dealt with that symptom in commit 28b047875, but really a more
straightforward and more efficient fix is to pass the data through in a new
field of struct PgFdwRelationInfo.  So do it that way.  (There's no need
to revert 28b047875, as it has sufficient reason to live anyway.)

Per fuzz testing by Andreas Seltenreich.

Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de

7 years agoAllow a rule on partitioned table to be renamed.
Robert Haas [Tue, 11 Apr 2017 17:17:22 +0000 (13:17 -0400)]
Allow a rule on partitioned table to be renamed.

Commit f0e44751d7175fa3394da2c8f85e3ceb3cdbfe63 should have updated
this code, but did not.

Amit Langote

Discussion: http://postgr.es/m/52d9c443-ec78-5c8a-7a77-0f34aad12b82@lab.ntt.co.jp

7 years agoAdd an Assert() to max_parallel_workers enforcement.
Robert Haas [Tue, 11 Apr 2017 17:03:44 +0000 (13:03 -0400)]
Add an Assert() to max_parallel_workers enforcement.

To prevent future bugs along the lines of the one corrected by commit
8ff518699f19dd0a5076f5090bac8400b8233f7f, or find any that remain
in the current code, add an Assert() that the difference between
parallel_register_count and parallel_terminate_count is in a sane
range.

Kuntal Ghosh, with considerable tidying-up by me, per a suggestion
from Neha Khatri.  Reviewed by Tomas Vondra.

Discussion: http://postgr.es/m/CAFO0U+-E8yzchwVnvn5BeRDPgX2z9vZUxQ8dxx9c0XFGBC7N1Q@mail.gmail.com

7 years agoFix confusion of max_parallel_workers mechanism following crash.
Robert Haas [Tue, 11 Apr 2017 16:31:00 +0000 (12:31 -0400)]
Fix confusion of max_parallel_workers mechanism following crash.

Commit b460f5d6693103076dc554aa7cbb96e1e53074f9 failed to contemplate
the possibilit that a parallel worker registered before a crash would
be unregistered only after the crash; if that happened, we'd end up
with parallel_terminate_count > parallel_register_count and the
system would refuse to launch any more parallel workers.

The easiest way to fix that seems to be to forget BGW_NEVER_RESTART
workers in ResetBackgroundWorkerCrashTimes() rather than leaving them
around to be cleaned up after the conclusion of the restart, so that
they go away before rather than after shared memory is reset.

To make sure that this fix is water-tight, don't allow parallel
workers to be anything other than BGW_NEVER_RESTART, so that after
recovering from a crash, 0 is guaranteed to be the correct starting
value for parallel_register_count.  The core code wouldn't do this
anyway, but somebody might try to do it in extension code.

Report by Thomas Vondra.  Patch by me, reviewed by Kuntal Ghosh.

Discussion: http://postgr.es/m/CAGz5QC+AVEVS+3rBKRq83AxkJLMZ1peMt4nnrQwczxOrmo3CNw@mail.gmail.com

7 years agodoc: clearify pg_upgrade default copy behavior
Bruce Momjian [Tue, 11 Apr 2017 16:14:01 +0000 (12:14 -0400)]
doc: clearify pg_upgrade default copy behavior

Reported-by: Marek <marek.cvoren@gmail.com>
Discussion: 20170328110253.2695.62609@wrigleys.postgresql.org

7 years agoFix failure when a shared tidbitmap has only one page.
Robert Haas [Tue, 11 Apr 2017 16:03:12 +0000 (12:03 -0400)]
Fix failure when a shared tidbitmap has only one page.

Commit 98e6e89040a0534ca26914c66cae9dd49ef62ad9 made inadequate
provision for the case of a single-page shared tidbitmap.  It
allocate space for a shared PagetableEntry, but failed to
initialize it.

Report by Thomas Munro.  Patch by Dilip Kumar, with some comment
changes by me.

Discussion: http://postgr.es/m/CAEepm=19Cmnfbi-j2Bw-a6yGPeHE1OVhKvvKz9bRBTJGKfGHMA@mail.gmail.com

7 years agoHandle restriction clause lists more uniformly in postgres_fdw.
Tom Lane [Tue, 11 Apr 2017 15:58:59 +0000 (11:58 -0400)]
Handle restriction clause lists more uniformly in postgres_fdw.

Clauses in the lists retained by postgres_fdw during planning were
sometimes bare boolean clauses, sometimes RestrictInfos, and sometimes
a mixture of the two in the same list.  The comment about that situation
didn't come close to telling the full truth, either.  Aside from being
confusing, this had a couple of bad practical consequences:
* waste of planning cycles due to inability to cache per-clause selectivity
and cost estimates;
* sometimes, RestrictInfos would sneak into the fdw_private list of a
finished Plan node, causing failures if, for example, we tried to ship
the Plan tree to a parallel worker.
(It may well be that it's a bug in the parallel-query logic that we
would ever try to ship such a plan to a parallel worker, but in any
case this deserves to be cleaned up.)

To fix, rearrange so that clause lists in PgFdwRelationInfo are always
lists of RestrictInfos, and then strip the RestrictInfos at the last
minute when making a Plan node.  In passing do a bit of refactoring and
comment cleanup in postgresGetForeignPlan and foreign_join_ok.

Although the messiness here dates back at least to 9.6, there's no evidence
that it causes anything worse than wasted planning cycles in 9.6, so no
back-patch for now.

Per fuzz testing by Andreas Seltenreich.

Tom Lane and Ashutosh Bapat

Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de

7 years agoAdd max_sync_workers_per_subscription to postgresql.conf.sample.
Fujii Masao [Tue, 11 Apr 2017 15:10:54 +0000 (00:10 +0900)]
Add max_sync_workers_per_subscription to postgresql.conf.sample.

This commit also does

- add REPLICATION_SUBSCRIBERS into config_group
- mark max_logical_replication_workers and max_sync_workers_per_subscription
  as REPLICATION_SUBSCRIBERS parameters
- move those parameters into "Subscribers" section in postgresql.conf.sample

Author: Masahiko Sawada, Petr Jelinek and me
Reported-by: Masahiko Sawada
Discussion: http://postgr.es/m/CAD21AoAonSCoa=v=87ZO3vhfUZA1k_E2XRNHTt=xioWGUa+0ug@mail.gmail.com

7 years agodocs: Improve window function docs
Bruce Momjian [Tue, 11 Apr 2017 14:47:40 +0000 (10:47 -0400)]
docs:  Improve window function docs

Specifically, the behavior of general-purpose and statistical aggregates
as window functions was not clearly documented, and terms were
inconsistently used.  Also add docs about the difference between
cume_dist and percent_rank, rather than just the formulas.

Discussion: 20170406214918.GA5757@momjian.us

7 years agoRemove symbol WIN32_ONLY_COMPILER
Magnus Hagander [Tue, 11 Apr 2017 13:21:25 +0000 (15:21 +0200)]
Remove symbol WIN32_ONLY_COMPILER

This used to mean "Visual C++ except in those parts where Borland C++
was supported where it meant one of those". Now that we don't support
Borland C++ anymore, simplify by using _MSC_VER which is the normal way
to detect Visual C++.

7 years agoRemove support for bcc and msvc standalone libpq builds
Magnus Hagander [Tue, 11 Apr 2017 13:14:26 +0000 (15:14 +0200)]
Remove support for bcc and msvc standalone libpq builds

This removes the support for building just libpq using Borland C++ or
Visual C++. This has not worked properly for years, and given the number
of complaints it's clearly not worth the maintenance burden.

Building libpq using the standard MSVC build system is of course still
supported, along with mingw.

7 years agoFix possibile deadlock when dropping partitions.
Robert Haas [Tue, 11 Apr 2017 13:08:36 +0000 (09:08 -0400)]
Fix possibile deadlock when dropping partitions.

heap_drop_with_catalog and RangeVarCallbackForDropRelation should
lock the parent before locking the target relation.

Amit Langote

Discussion: http://postgr.es/m/29588799-a8ce-b0a2-3dae-f39ff6d35922@lab.ntt.co.jp

7 years agoFix pgbench's --progress-timestamp option to print Unix-epoch timestamps.
Tom Lane [Tue, 11 Apr 2017 12:59:40 +0000 (08:59 -0400)]
Fix pgbench's --progress-timestamp option to print Unix-epoch timestamps.

As a consequence of commit 1d63f7d2d, on platforms with CLOCK_MONOTONIC,
you got some random timescale or other instead of standard Unix timestamps
as expected.  I'd attempted to fix pgbench for that change in commits
74baa1e3b and 67a875355, but missed this place.  Fix in the same way as
those previous commits, ie, just eat the cost of an extra gettimeofday();
one extra syscall per progress report isn't worth sweating over.  Per
report from Jeff Janes.

In passing, use snprintf not sprintf for this purpose.  I don't think
there's any chance of actual buffer overrun, but it just looks safer.

Discussion: https://postgr.es/m/CAMkU=1zrQaPwBN+NcBd3pWCb=vWaiL=mmWfJjDJjh-a7eVr-Og@mail.gmail.com

7 years agoDocument that bytea is best represented as char * in C for ecpg.
Michael Meskes [Tue, 11 Apr 2017 10:41:06 +0000 (12:41 +0200)]
Document that bytea is best represented as char * in C for ecpg.

Patch by Kato, Sho <kato-sho@jp.fujitsu.com>

7 years agoRun most pg_dump and pg_dumpall tests with --no-sync
Andrew Dunstan [Mon, 10 Apr 2017 23:53:47 +0000 (19:53 -0400)]
Run most pg_dump and pg_dumpall tests with --no-sync

Commit 96a7128b made pg_dump and pg_dumpall sync their output by
default. However, there's no great need for that in testing, and it
could impose a performance penalty, so we add the --no-sync flag to most
of the test cases.

Michael Paquier

7 years agoUse weaker locks when updating pg_subscription_rel
Peter Eisentraut [Mon, 10 Apr 2017 19:08:14 +0000 (15:08 -0400)]
Use weaker locks when updating pg_subscription_rel

The previously used ShareRowExclusiveLock, while technically probably
more correct, led to deadlocks during seemingly unrelated operations and
thus a poor experience.  Use RowExclusiveLock, like for most similar
catalog operations.  In some care cases, the user might see an error
from DDL commands.

Discussion: https://www.postgresql.org/message-id/flat/13592.1490851519%40sss.pgh.pa.us

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

7 years agoFix initialization of dsa.c free area counter.
Andres Freund [Mon, 10 Apr 2017 18:56:46 +0000 (11:56 -0700)]
Fix initialization of dsa.c free area counter.

The backend local copy of dsa_area_control->freed_segment_counter was
not properly initialized / maintained.  This could, if unlucky, lead
to keeping attached to a segment for too long.

Found via valgrind bleat on buildfarm animal skink.

Author: Thomas Munro
Discussion: https://postgr.es/m/20170407164935.obsf2jipjfos5zei@alap3.anarazel.de

7 years agoImprove castNode notation by introducing list-extraction-specific variants.
Tom Lane [Mon, 10 Apr 2017 17:51:29 +0000 (13:51 -0400)]
Improve castNode notation by introducing list-extraction-specific variants.

This extends the castNode() notation introduced by commit 5bcab1114 to
provide, in one step, extraction of a list cell's pointer and coercion to
a concrete node type.  For example, "lfirst_node(Foo, lc)" is the same
as "castNode(Foo, lfirst(lc))".  Almost half of the uses of castNode
that have appeared so far include a list extraction call, so this is
pretty widely useful, and it saves a few more keystrokes compared to the
old way.

As with the previous patch, back-patch the addition of these macros to
pg_list.h, so that the notation will be available when back-patching.

Patch by me, after an idea of Andrew Gierth's.

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

7 years agoFix typo in comment
Peter Eisentraut [Mon, 10 Apr 2017 17:42:05 +0000 (13:42 -0400)]
Fix typo in comment

7 years agoSupport configuration reload in logical replication workers
Peter Eisentraut [Mon, 10 Apr 2017 17:40:55 +0000 (13:40 -0400)]
Support configuration reload in logical replication workers

Author: Michael Paquier <michael.paquier@gmail.com>
Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reported-by: Fujii Masao <masao.fujii@gmail.com>
7 years agoFix reporting of violations in ExecConstraints, again.
Robert Haas [Mon, 10 Apr 2017 16:20:08 +0000 (12:20 -0400)]
Fix reporting of violations in ExecConstraints, again.

We decided in f1b4c771ea74f42447dccaed42ffcdcccf3aa694 to pass the
original slot to ExecConstraints(), but that breaks when there are
BEFORE ROW triggers involved.  So we need to do reverse-map the tuples
back to the original descriptor instead, as Amit originally proposed.

Amit Langote, reviewed by Ashutosh Bapat.  One overlooked comment
fixed by me.

Discussion: http://postgr.es/m/b3a17254-6849-e542-2353-bde4e880b6a4@lab.ntt.co.jp

7 years agoFix whitespace
Peter Eisentraut [Mon, 10 Apr 2017 15:18:15 +0000 (11:18 -0400)]
Fix whitespace

7 years agoMove isolationtester's is-blocked query into C code for speed.
Tom Lane [Mon, 10 Apr 2017 14:26:54 +0000 (10:26 -0400)]
Move isolationtester's is-blocked query into C code for speed.

Commit 4deb41381 modified isolationtester's query to see whether a
session is blocked to also check for waits occurring in GetSafeSnapshot.
However, it did that in a way that enormously increased the query's
runtime under CLOBBER_CACHE_ALWAYS, causing the buildfarm members
that use that to run about four times slower than before, and in some
cases fail entirely.  To fix, push the entire logic into a dedicated
backend function.  This should actually reduce the CLOBBER_CACHE_ALWAYS
runtime from what it was previously, though I've not checked that.

In passing, expose a SQL function to check for safe-snapshot blockage,
comparable to pg_blocking_pids.  This is more or less free given the
infrastructure built to solve the other problem, so we might as well.

Thomas Munro

Discussion: https://postgr.es/m/20170407165749.pstcakbc637opkax@alap3.anarazel.de

7 years agoFix indentation.
Heikki Linnakangas [Mon, 10 Apr 2017 11:13:15 +0000 (14:13 +0300)]
Fix indentation.

Oops, I forgot to "git add" this to previous commit.

7 years agoDocument the "replication" option in StartupMessage.
Heikki Linnakangas [Mon, 10 Apr 2017 11:08:20 +0000 (14:08 +0300)]
Document the "replication" option in StartupMessage.

It is documented in the Streaming Replication Protocol section, but was
missing from the list of options in StartupMessage description.

7 years agoMake sepgsql regression tests robust vs. collation differences
Joe Conway [Sun, 9 Apr 2017 22:59:02 +0000 (15:59 -0700)]
Make sepgsql regression tests robust vs. collation differences

In commit 25542d77, regression test coverage was added to sepgsql
for partitioned tables. Unfortunately it was not robust in the face
of collation differences, per the buildfarm. Force "C" collation
in order to fix that.

Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com

7 years agoAdd partitioned table support to sepgsql
Joe Conway [Sun, 9 Apr 2017 21:01:58 +0000 (14:01 -0700)]
Add partitioned table support to sepgsql

The new partitioned table capability added a new relkind, namely
RELKIND_PARTITIONED_TABLE. Update sepgsql to treat this new relkind
exactly the same way it does RELKIND_RELATION.

In addition, add regression test coverage for partitioned tables.

Issue raised by Stephen Frost and initial patch by Mike Palmiotto.
Review by Tom Lane and Robert Haas, and editorializing by me.

Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com

7 years agoClean up bugs in clause_selectivity() cleanup.
Tom Lane [Sat, 8 Apr 2017 20:38:03 +0000 (16:38 -0400)]
Clean up bugs in clause_selectivity() cleanup.

Commit ac2b09508 was not terribly carefully reviewed.  Band-aid it to
not fail on non-RestrictInfo input, per report from Andreas Seltenreich.
Also make it do something more reasonable with variable-free clauses,
and improve nearby comments.

Discussion: https://postgr.es/m/87inmf5rdx.fsf@credativ.de

7 years agoAdd newly-symlinked files to "make clean" target.
Tom Lane [Sat, 8 Apr 2017 18:25:45 +0000 (14:25 -0400)]
Add newly-symlinked files to "make clean" target.

Oversight in 60f11b87a.

7 years agoFix the new SASLprep tests to work with non-UTF-8 locales.
Heikki Linnakangas [Sat, 8 Apr 2017 10:32:38 +0000 (13:32 +0300)]
Fix the new SASLprep tests to work with non-UTF-8 locales.

Fix by forcing database encoding to UTF-8, regardless of the current
locale.

Pointed out by Tom Lane.

Discussion: https://www.postgresql.org/message-id/8934.1491614631@sss.pgh.pa.us

7 years agodoc: Add some markup
Peter Eisentraut [Sat, 8 Apr 2017 02:42:03 +0000 (22:42 -0400)]
doc: Add some markup

7 years agoAdd GUCs for predicate lock promotion thresholds.
Kevin Grittner [Sat, 8 Apr 2017 02:38:05 +0000 (21:38 -0500)]
Add GUCs for predicate lock promotion thresholds.

Defaults match the fixed behavior of prior releases, but now DBAs
have better options to tune serializable workloads.

It might be nice to be able to set this per relation, but that part
will need to wait for another release.

Author: Dagfinn Ilmari Mannsåker

7 years agoOptimize joins when the inner relation can be proven unique.
Tom Lane [Sat, 8 Apr 2017 02:20:03 +0000 (22:20 -0400)]
Optimize joins when the inner relation can be proven unique.

If there can certainly be no more than one matching inner row for a given
outer row, then the executor can move on to the next outer row as soon as
it's found one match; there's no need to continue scanning the inner
relation for this outer row.  This saves useless scanning in nestloop
and hash joins.  In merge joins, it offers the opportunity to skip
mark/restore processing, because we know we have not advanced past the
first possible match for the next outer row.

Of course, the devil is in the details: the proof of uniqueness must
depend only on joinquals (not otherquals), and if we want to skip
mergejoin mark/restore then it must depend only on merge clauses.
To avoid adding more planning overhead than absolutely necessary,
the present patch errs in the conservative direction: there are cases
where inner_unique or skip_mark_restore processing could be used, but
it will not do so because it's not sure that the uniqueness proof
depended only on "safe" clauses.  This could be improved later.

David Rowley, reviewed and rather heavily editorialized on by me

Discussion: https://postgr.es/m/CAApHDvqF6Sw-TK98bW48TdtFJ+3a7D2mFyZ7++=D-RyPsL76gw@mail.gmail.com

7 years agoFix issues in e8fdbd58fe.
Andres Freund [Sat, 8 Apr 2017 00:03:21 +0000 (17:03 -0700)]
Fix issues in e8fdbd58fe.

When the 64bit atomics simulation is in use, we can't necessarily
guarantee the correct alignment of the atomics due to lack of compiler
support for doing so- that's fine from a safety perspective, because
everything is protected by a lock, but we asserted the alignment in
all cases.  Weaken them.  Per complaint from Alvaro Herrera.

My #ifdefery for PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY wasn't
sufficient. Fix that.  Per complaint from Alexander Korotkov.

7 years agodoc: Add SPFLAGS to osx calls
Peter Eisentraut [Fri, 7 Apr 2017 22:26:06 +0000 (18:26 -0400)]
doc: Add SPFLAGS to osx calls

This enables the same OpenSP warnings on osx calls that we get from
onsgmls (make check) and formerly from openjade.

Older tool chains apparently have some of these warnings on by
default (see comment at SPFLAGS assignment).  So users of such tool
chains would complain about warnings or errors that users of newer tool
chains would not see, unless they used "make check".

7 years agodoc: Add missing closing tag
Peter Eisentraut [Fri, 7 Apr 2017 22:25:24 +0000 (18:25 -0400)]
doc: Add missing closing tag

Author: Erik Rijkers <er@xs4all.nl>

7 years agoFix printf format to use %zd when printing sizes
Alvaro Herrera [Fri, 7 Apr 2017 22:27:00 +0000 (19:27 -0300)]
Fix printf format to use %zd when printing sizes

Using %ld as we were doing raises compiler warnings on 32 bit platforms.

Reported by Andres Freund.
Discussion: https://postgr.es/m/20170407214022.fidezl2e6rk3tuiz@alap3.anarazel.de

7 years agoReduce the number of pallocs() in BRIN
Alvaro Herrera [Fri, 7 Apr 2017 21:54:26 +0000 (18:54 -0300)]
Reduce the number of pallocs() in BRIN

Instead of allocating memory in brin_deform_tuple and brin_copy_tuple
over and over during a scan, allow reuse of previously allocated memory.
This is said to make for a measurable performance improvement.

Author: Jinyu Zhang, Álvaro Herrera
Reviewed by: Tomas Vondra
Discussion: https://postgr.es/m/495deb78.4186.1500dacaa63.Coremail.beijing_pg@163.com

7 years agoImprove 64bit atomics support.
Andres Freund [Fri, 7 Apr 2017 21:44:47 +0000 (14:44 -0700)]
Improve 64bit atomics support.

When adding atomics back in b64d92f1a, I added 64bit support as
optional; there wasn't yet a direct user in sight.  That turned out to
be a bit short-sighted, it'd already have been useful a number of times.

Add a fallback implementation of 64bit atomics, just like the one we
have for 32bit atomics.

Additionally optimize reads/writes to 64bit on a number of platforms
where aligned writes of that size are atomic. This can now be tested
with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY.

Author: Andres Freund
Reviewed-By: Amit Kapila
Discussion: https://postgr.es/m/20160330230914.GH13305@awork2.anarazel.de

7 years agoFix compiler warning
Peter Eisentraut [Fri, 7 Apr 2017 21:37:12 +0000 (17:37 -0400)]
Fix compiler warning

on MSVC 2010

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

7 years agoAvoid using a C++ keyword in header file
Peter Eisentraut [Fri, 7 Apr 2017 20:32:02 +0000 (16:32 -0400)]
Avoid using a C++ keyword in header file

per cpluspluscheck

7 years agoFix new BRIN desummarize WAL record
Alvaro Herrera [Fri, 7 Apr 2017 19:58:54 +0000 (16:58 -0300)]
Fix new BRIN desummarize WAL record

The WAL-writing piece was forgetting to set the pages-per-range value.
Also, fix the declared type of struct member heapBlk, which I mistakenly
set as OffsetNumber rather than BlockNumber.

Problem was introduced by commit c655899ba9ae (April 1st).  Any system
that tries to replay the new WAL record written before this fix is
likely to die on replay and require pg_resetwal.

Reported by Tom Lane.
Discussion: https://postgr.es/m/20191.1491524824@sss.pgh.pa.us

7 years agoUse English, instead of internal names, for translatable messages.
Robert Haas [Fri, 7 Apr 2017 19:38:46 +0000 (15:38 -0400)]
Use English, instead of internal names, for translatable messages.

Discussion: http://postgr.es/m/CA+Tgmobuz2C-YiQ87h8h0gECCV=F+SE=HBNaAU75rR5FEwtEhQ@mail.gmail.com

7 years agoAdd ProcArrayGroupUpdate wait event.
Robert Haas [Fri, 7 Apr 2017 17:41:47 +0000 (13:41 -0400)]
Add ProcArrayGroupUpdate wait event.

Discussion: http://postgr.es/m/CA+TgmobgWHcXDcChX2+BqJDk2dkPVF85ZrJFhUyHHQmw8diTpA@mail.gmail.com

7 years agoEnsure that ExecPrepareExprList's result is all in one memory context.
Tom Lane [Fri, 7 Apr 2017 16:54:17 +0000 (12:54 -0400)]
Ensure that ExecPrepareExprList's result is all in one memory context.

Noted by Amit Langote.

Discussion: https://postgr.es/m/aad31672-4983-d95d-d24e-6b42fee9b985@lab.ntt.co.jp

7 years agoRemove duplicate assignment.
Heikki Linnakangas [Fri, 7 Apr 2017 16:19:50 +0000 (19:19 +0300)]
Remove duplicate assignment.

Harmless, but clearly wrong.

Kyotaro Horiguchi

7 years agoFix planner error (or assert trap) with nested set operations.
Tom Lane [Fri, 7 Apr 2017 16:18:38 +0000 (12:18 -0400)]
Fix planner error (or assert trap) with nested set operations.

As reported by Sean Johnston in bug #14614, since 9.6 the planner can fail
due to trying to look up the referent of a Var with varno 0.  This happens
because we generate such Vars in generate_append_tlist, for lack of any
better way to describe the output of a SetOp node.  In typical situations
nothing really cares about that, but given nested set-operation queries
we will call estimate_num_groups on the output of the subquery, and that
wants to know what a Var actually refers to.  That logic used to look at
subquery->targetList, but in commit 3fc6e2d7f I'd switched it to look at
subroot->processed_tlist, ie the actual output of the subquery plan not the
parser's idea of the result.  It seemed like a good idea at the time :-(.
As a band-aid fix, change it back.

Really we ought to have an honest way of naming the outputs of SetOp steps,
which suggests that it'd be a good idea for the parser to emit an RTE
corresponding to each one.  But that's a task for another day, and it
certainly wouldn't yield a back-patchable fix.

Report: https://postgr.es/m/20170407115808.25934.51866@wrigleys.postgresql.org

7 years agoUse SASLprep to normalize passwords for SCRAM authentication.
Heikki Linnakangas [Fri, 7 Apr 2017 11:56:05 +0000 (14:56 +0300)]
Use SASLprep to normalize passwords for SCRAM authentication.

An important step of SASLprep normalization, is to convert the string to
Unicode normalization form NFKC. Unicode normalization requires a fairly
large table of character decompositions, which is generated from data
published by the Unicode consortium. The script to generate the table is
put in src/common/unicode, as well test code for the normalization.
A pre-generated version of the tables is included in src/include/common,
so you don't need the code in src/common/unicode to build PostgreSQL, only
if you wish to modify the normalization tables.

The SASLprep implementation depends on the UTF-8 functions from
src/backend/utils/mb/wchar.c. So to use it, you must also compile and link
that. That doesn't change anything for the current users of these
functions, the backend and libpq, as they both already link with wchar.o.
It would be good to move those functions into a separate file in
src/commmon, but I'll leave that for another day.

No documentation changes included, because there is no details on the
SCRAM mechanism in the docs anyway. An overview on that in the protocol
specification would probably be good, even though SCRAM is documented in
detail in RFC5802. I'll write that as a separate patch. An important thing
to mention there is that we apply SASLprep even on invalid UTF-8 strings,
to support other encodings.

Patch by Michael Paquier and me.

Discussion: https://www.postgresql.org/message-id/CAB7nPqSByyEmAVLtEf1KxTRh=PWNKiWKEKQR=e1yGehz=wbymQ@mail.gmail.com

7 years agoFix typo in comment
Magnus Hagander [Fri, 7 Apr 2017 07:30:22 +0000 (09:30 +0200)]
Fix typo in comment

Masahiko Sawada

7 years agoRemove extraneous comma to satisfy picky compiler
Andrew Dunstan [Fri, 7 Apr 2017 03:28:14 +0000 (23:28 -0400)]
Remove extraneous comma to satisfy picky compiler

per buildfarm

7 years agoMake json_populate_record and friends operate recursively
Andrew Dunstan [Fri, 7 Apr 2017 02:11:21 +0000 (22:11 -0400)]
Make json_populate_record and friends operate recursively

With this change array fields are populated from json(b) arrays, and
composite fields are populated from json(b) objects.

Along the way, some significant code refactoring is done to remove
redundancy in the way to populate_record[_set] and to_record[_set]
functions operate, and some significant efficiency gains are made by
caching tuple descriptors.

Nikita Glukhov, edited some by me.

Reviewed by Aleksander Alekseev and Tom Lane.

7 years agoRemove use of Jade and DSSSL
Peter Eisentraut [Fri, 7 Apr 2017 02:03:52 +0000 (22:03 -0400)]
Remove use of Jade and DSSSL

All documentation is now built using XSLT.  Remove all references to
Jade, DSSSL, also JadeTex and some other outdated tooling.

For chunked HTML builds, this changes nothing, but removes the
transitional "oldhtml" target.  The single-page HTML build is ported
over to XSLT.  For PDF builds, this removes the JadeTex builds and moves
the FOP builds in their place.

7 years agoClean up after insufficiently-researched optimization of tuple conversions.
Tom Lane [Fri, 7 Apr 2017 01:10:09 +0000 (21:10 -0400)]
Clean up after insufficiently-researched optimization of tuple conversions.

tupconvert.c's functions formerly considered that an explicit tuple
conversion was necessary if the input and output tupdescs contained
different type OIDs.  The point of that was to make sure that a composite
datum resulting from the conversion would contain the destination rowtype
OID in its composite-datum header.  However, commit 3838074f8 entirely
misunderstood what that check was for, thinking that it had something to do
with presence or absence of an OID column within the tuple.  Removal of the
check broke the no-op conversion path in ExecEvalConvertRowtype, as
reported by Ashutosh Bapat.

It turns out that of the dozen or so call sites for tupconvert.c functions,
ExecEvalConvertRowtype is the only one that cares about the composite-datum
header fields in the output tuple.  In all the rest, we'd much rather avoid
an unnecessary conversion whenever the tuples are physically compatible.
Moreover, the comments in tupconvert.c only promise physical compatibility
not a metadata match.  So, let's accept the removal of the guarantee about
the output tuple's rowtype marking, recognizing that this is a API change
that could conceivably break third-party callers of tupconvert.c.  (So,
let's remember to mention it in the v10 release notes.)

However, commit 3838074f8 did have a bit of a point here, in that two
tuples mustn't be considered physically compatible if one has HEAP_HASOID
set and the other doesn't.  (Some of the callers of tupconvert.c might not
really care about that, but we can't assume it in general.)  The previous
check accidentally covered that issue, because no RECORD types ever have
OIDs, while if two tupdescs have the same named composite type OID then,
a fortiori, they have the same tdhasoid setting.  If we're removing the
type OID match check then we'd better include tdhasoid match as part of
the physical compatibility check.

Without that hack in tupconvert.c, we need ExecEvalConvertRowtype to take
responsibility for inserting the correct rowtype OID label whenever
tupconvert.c decides it need not do anything.  This is easily done with
heap_copy_tuple_as_datum, which will be considerably faster than a tuple
disassembly and reassembly anyway; so from a performance standpoint this
change is a win all around compared to what happened in earlier branches.
It just means a couple more lines of code in ExecEvalConvertRowtype.

Ashutosh Bapat and Tom Lane

Discussion: https://postgr.es/m/CAFjFpRfvHABV6+oVvGcshF8rHn+1LfRUhj7Jz1CDZ4gPUwehBg@mail.gmail.com

7 years agoReset API of clause_selectivity()
Simon Riggs [Thu, 6 Apr 2017 23:10:51 +0000 (19:10 -0400)]
Reset API of clause_selectivity()

Discussion: https://postgr.es/m/CAKJS1f9yurJQW9pdnzL+rmOtsp2vOytkpXKGnMFJEO-qz5O5eA@mail.gmail.com

7 years agoFix the RTE_NAMEDTUPLESTORE case in get_rte_attribute_is_dropped().
Kevin Grittner [Thu, 6 Apr 2017 22:32:53 +0000 (17:32 -0500)]
Fix the RTE_NAMEDTUPLESTORE case in get_rte_attribute_is_dropped().

Problems pointed out by Andres Freund and Thomas Munro.

7 years agoAllow avoiding tuple copy within tuplesort_gettupleslot().
Andres Freund [Thu, 6 Apr 2017 21:48:59 +0000 (14:48 -0700)]
Allow avoiding tuple copy within tuplesort_gettupleslot().

Add a "copy" argument to make it optional to receive a copy of caller
tuple that is safe to use following a subsequent manipulating of
tuplesort's state.  This is a performance optimization.  Most existing
tuplesort_gettupleslot() callers are made to opt out of copying.
Existing callers that happen to rely on the validity of tuple memory
beyond subsequent manipulations of the tuplesort request their own
copy.

This brings tuplesort_gettupleslot() in line with
tuplestore_gettupleslot().  In the future, a "copy"
tuplesort_getdatum() argument may be added, that similarly allows
callers to opt out of receiving their own copy of tuple.

In passing, clarify assumptions that callers of other tuplesort fetch
routines may make about tuple memory validity, per gripe from Tom
Lane.

Author: Peter Geoghegan
Discussion: CAM3SWZQWZZ_N=DmmL7tKy_OUjGH_5mN=N=A6h7kHyyDvEhg2DA@mail.gmail.com

7 years agoSilence uninitialized variable compiler warning in sepgsql
Joe Conway [Thu, 6 Apr 2017 21:28:19 +0000 (14:28 -0700)]
Silence uninitialized variable compiler warning in sepgsql

At -Og optimization gcc warns that variable tclass may be used
uninitialized when relkind == RELKIND_INDEX. Actually that can't
happen due to an early return, but quiet the compiler by initializing
tclass to 0.

In passing, use uint16_t consistently for the declaration of tclass.

Complaint and initial patch by Mike Palmiotto. Editorializing by me.
Probably not worth backpatching given that it is cosmetic, so apply
to development head only.

Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com

7 years agoSilence compiler warning in sepgsql
Joe Conway [Thu, 6 Apr 2017 21:21:25 +0000 (14:21 -0700)]
Silence compiler warning in sepgsql

<selinux/label.h> includes <stdbool.h>, which creates an incompatible
We don't care if <stdbool.h> redefines "true"/"false"; those are close
enough.

Complaint and initial patch by Mike Palmiotto. Final approach per
Tom Lane's suggestion, as discussed on hackers. Backpatching to
all supported branches.

Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com

7 years agoFix parallel bitmapscan tests on builds without USE_PREFETCH.
Andres Freund [Thu, 6 Apr 2017 21:21:39 +0000 (14:21 -0700)]
Fix parallel bitmapscan tests on builds without USE_PREFETCH.

This was broken in 5a5931533edd2.

7 years agoFix BRIN cost estimation
Alvaro Herrera [Thu, 6 Apr 2017 20:49:26 +0000 (17:49 -0300)]
Fix BRIN cost estimation

The original code was overly optimistic about the cost of scanning a
BRIN index, leading to BRIN indexes being selected when they'd be a
worse choice than some other index.  This complete rewrite should be
more accurate.

Author: David Rowley, based on an earlier patch by Emre Hasegeli
Reviewed-by: Emre Hasegeli
Discussion: https://postgr.es/m/CAKJS1f9n-Wapop5Xz1dtGdpdqmzeGqQK4sV2MK-zZugfC14Xtw@mail.gmail.com

7 years agoAdd minimal test for EXPLAIN ANALYZE of parallel query.
Andres Freund [Thu, 6 Apr 2017 20:44:48 +0000 (13:44 -0700)]
Add minimal test for EXPLAIN ANALYZE of parallel query.

This displays the number of workers launched, thus the test is
dependant on configuration to some degree.  We'll see whether that
turns out ot be a problem.

Author: Rafia Sabih
Discussion: https://postgr.es/m/20170331185540.zmsue4ndvqtnayqw@alap3.anarazel.de

7 years agoIncrease parallel bitmap scan test coverage.
Andres Freund [Thu, 6 Apr 2017 20:36:54 +0000 (13:36 -0700)]
Increase parallel bitmap scan test coverage.

Author: Dilip Kumar
Discussion: https://postgr.es/m/20170331184603.qcp7t4md5bzxbx32@alap3.anarazel.de

7 years agoFix logical replication between different encodings
Peter Eisentraut [Wed, 5 Apr 2017 14:44:23 +0000 (10:44 -0400)]
Fix logical replication between different encodings

When sending a tuple attribute, the previous coding erroneously sent the
length byte before encoding conversion, which would lead to protocol
failures on the receiving side if the length did not match the following
string.

To fix that, use pq_sendcountedtext() for sending tuple attributes,
which takes care of all of that internally.  To match the API of
pq_sendcountedtext(), send even text values without a trailing zero byte
and have the receiving end put it in place instead.  This matches how
the standard FE/BE protocol behaves.

Reported-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
7 years agoMark immutable functions in information schema as parallel safe
Peter Eisentraut [Wed, 5 Apr 2017 16:17:03 +0000 (12:17 -0400)]
Mark immutable functions in information schema as parallel safe

Also add opr_sanity check that all preloaded immutable functions are
parallel safe.  (Per discussion, this does not necessarily have to be
true for all possible such functions, but deviations would be unlikely
enough that maintaining such a test is reasonable.)

Reported-by: David Rowley <david.rowley@2ndquadrant.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
7 years agopg_dump: Rename some typedefs to avoid name conflicts
Peter Eisentraut [Tue, 30 Aug 2016 16:00:00 +0000 (12:00 -0400)]
pg_dump: Rename some typedefs to avoid name conflicts

In struct _archiveHandle, some of the fields have the same name as a
typedef.  This is kind of confusing, so rename the types so they have
names distinct from the struct fields.  In C++, the previous coding
changes the meaning of the typedef in the scope of the struct, causing
warnings and possibly other problems.

Reviewed-by: Andres Freund <andres@anarazel.de>
7 years agoClean up psql/describe.c's messy query for extended stats.
Tom Lane [Thu, 6 Apr 2017 17:21:40 +0000 (13:21 -0400)]
Clean up psql/describe.c's messy query for extended stats.

Remove unnecessary casts, safely schema-qualify the ones that remain,
lose an unnecessary level of sub-SELECT, reformat for tidiness.

7 years agoFix mixup of bool and ternary value
Peter Eisentraut [Tue, 30 Aug 2016 16:00:00 +0000 (12:00 -0400)]
Fix mixup of bool and ternary value

Not currently a problem, but could be with stricter bool behavior under
stdbool or C++.

Reviewed-by: Andres Freund <andres@anarazel.de>
7 years agodoc: Formatting fix for XSL-FO PDF build
Peter Eisentraut [Thu, 6 Apr 2017 16:27:45 +0000 (12:27 -0400)]
doc: Formatting fix for XSL-FO PDF build

7 years agoFix AclResult vs bool type mix-up
Peter Eisentraut [Thu, 6 Apr 2017 15:31:18 +0000 (11:31 -0400)]
Fix AclResult vs bool type mix-up

Using AclResult as a bool or vice versa works by accident, but it's
unusual and possibly confusing style, so write it out more explicitly.

7 years agoComment fixes for extended statistics
Alvaro Herrera [Thu, 6 Apr 2017 15:27:15 +0000 (12:27 -0300)]
Comment fixes for extended statistics

Clean up some code comments in new extended statistics code, from
7b504eb282.

7 years agoFix compiler warning and add some more comments
Peter Eisentraut [Thu, 6 Apr 2017 15:17:43 +0000 (11:17 -0400)]
Fix compiler warning and add some more comments

7 years agoRemove bogus SCRAM_ITERATION_LEN constant.
Heikki Linnakangas [Thu, 6 Apr 2017 14:41:48 +0000 (17:41 +0300)]
Remove bogus SCRAM_ITERATION_LEN constant.

It was not used for what the comment claimed, at all. It was actually used
as the 'base' argument to strtol(), when reading the iteration count. We
don't need a constant for base-10, so remove it.

7 years agoAlways SnapshotResetXmin() during ClearTransaction()
Simon Riggs [Thu, 6 Apr 2017 14:30:22 +0000 (10:30 -0400)]
Always SnapshotResetXmin() during ClearTransaction()

Avoid corner cases during 2PC with 6bad580d9e678a0b604883e14d8401d469b06566