]> granicus.if.org Git - postgresql/log
postgresql
7 years agoSimplify the example of VACUUM in documentation.
Fujii Masao [Thu, 30 Mar 2017 16:31:15 +0000 (01:31 +0900)]
Simplify the example of VACUUM in documentation.

Previously a detailed activity report by VACUUM VERBOSE ANALYZE was
described as an example of VACUUM in docs. But it had been obsolete
for a long time. For example, commit feb4f44d296b88b7f0723f4a4f3945a371276e0b
updated the content of that activity report in 2003, but we had
forgotten to update the example.

So basically we need to update the example. But since no one cared
about the details of VACUUM output and complained about that mistake
for such long time, per discussion on hackers, we decided to get rid
of the detailed activity report from the example and simplify it.

Back-patch to all supported versions.

Reported by Masahiko Sawada, patch by me.
Discussion: https://postgr.es/m/CAD21AoAGA2pB3p-CWmTkxBsbkZS1bcDGBLcYVcvcDxspG_XAfA@mail.gmail.com

7 years agoRemove support for version-0 calling conventions.
Andres Freund [Wed, 29 Mar 2017 20:16:49 +0000 (13:16 -0700)]
Remove support for version-0 calling conventions.

The V0 convention is failure prone because we've so far assumed that a
function is V0 if PG_FUNCTION_INFO_V1 is missing, leading to crashes
if a function was coded against the V1 interface.  V0 doesn't allow
proper NULL, SRF and toast handling.  V0 doesn't offer features that
V1 doesn't.

Thus remove V0 support and obsolete fmgr README contents relating to
it.

Author: Andres Freund, with contributions by Peter Eisentraut & Craig Ringer
Reviewed-By: Peter Eisentraut, Craig Ringer
Discussion: https://postgr.es/m/20161208213441.k3mbno4twhg2qf7g@alap3.anarazel.de

7 years agoMove contrib/seg to only use V1 calling conventions.
Andres Freund [Wed, 29 Mar 2017 20:16:30 +0000 (13:16 -0700)]
Move contrib/seg to only use V1 calling conventions.

A later commit will remove V0 support.

Author: Andres Freund, with contributions by Craig Ringer
Reviewed-By: Peter Eisentraut, Craig Ringer
Discussion: https://postgr.es/m/20161208213441.k3mbno4twhg2qf7g@alap3.anarazel.de

7 years agoImplement SortSupport for macaddr data type
Teodor Sigaev [Wed, 29 Mar 2017 20:28:56 +0000 (23:28 +0300)]
Implement SortSupport for macaddr data type

Introduces a scheme to produce abbreviated keys for the macaddr type.
Bump catalog version.

Author: Brandur Leach
Reviewed-by: Julien Rouhaud, Peter Geoghegan
https://commitfest.postgresql.org/13/743/

7 years agopg_dump: Remove query truncation in error messages
Peter Eisentraut [Wed, 29 Mar 2017 19:17:14 +0000 (15:17 -0400)]
pg_dump: Remove query truncation in error messages

Remove the behavior that a query mentioned in an error message would be
truncated to 128 characters.  The queries that pg_dump runs are often
longer than that, and this behavior makes analyzing failures harder
unnecessarily.

Discussion: https://www.postgresql.org/message-id/flat/63201ef9-26fb-3f1f-664d-98531678cebc%402ndquadrant.com

7 years agoUpdate copyright year in recently added files
Peter Eisentraut [Wed, 29 Mar 2017 18:54:10 +0000 (14:54 -0400)]
Update copyright year in recently added files

Author: Masahiko Sawada <sawada.mshk@gmail.com>

7 years agoSimplify check of modified attributes in heap_update
Alvaro Herrera [Wed, 29 Mar 2017 15:18:48 +0000 (12:18 -0300)]
Simplify check of modified attributes in heap_update

The old coding was getting more complicated as new things were added,
and it would be barely tolerable with upcoming WARM updates and other
future features such as indirect indexes.  The new coding incurs a small
performance cost in synthetic benchmark cases, and is barely measurable
in normal cases.  A much larger benefit is expected from WARM, which
could actually bolt its needs on top of the existing coding, but it is
much uglier and bug-prone than doing it on this new code.  Additional
optimization can be applied on top of this, if need be.

Reviewed-by: Pavan Deolasee, Amit Kapila, Mithun CY
Discussion: https://postgr.es/m/20161228232018.4hc66ndrzpz4g4wn@alvherre.pgsql
https://postgr.es/m/CABOikdMJfz69dBNRTOZcB6s5A0tf8OMCyQVYQyR-WFFdoEwKMQ@mail.gmail.com

7 years agoMark more functions parallel-restricted.
Robert Haas [Wed, 29 Mar 2017 14:59:27 +0000 (10:59 -0400)]
Mark more functions parallel-restricted.

Commit 61c2e1a95f94bb904953a6281ce17a18ac38ee6d allowed parallel
query to be used in more places, revealing via buildfarm member
mandrill that several functions intended to be called from triggers
were incorrectly marked parallel-safe rather than parallel-restricted.

Report by Tom Lane.  Patch by Rafia Sabih.  Reviewed by me.

Discussion: http://postgr.es/m/16061.1490479253@sss.pgh.pa.us

7 years agoPlug race in dsa_attach.
Robert Haas [Wed, 29 Mar 2017 13:44:29 +0000 (09:44 -0400)]
Plug race in dsa_attach.

With sufficiently bad luck, it was possible for a parallel worker to
attempt attach to a DSA area after all other backends have detached
from it, which is not legal.  If the worker had waited a little longer
to get started, the DSM itself would have been destroyed, which is why
this wasn't noticed before.

Thomas Munro, per a report from Andreas Seltenreich

Discussion: http://postgr.es/m/87h92g83t3.fsf@credativ.de

7 years agoFix hardcoded typeof check result for Windows
Peter Eisentraut [Wed, 29 Mar 2017 12:55:34 +0000 (08:55 -0400)]
Fix hardcoded typeof check result for Windows

The test result that I had blindly stipulated didn't work out on the
build farm, so disable the feature in Windows MSVC for now.

7 years agoFix configure check for typeof
Peter Eisentraut [Wed, 29 Mar 2017 02:28:56 +0000 (22:28 -0400)]
Fix configure check for typeof

7 years agoImprove Node vs Expr use a bit
Peter Eisentraut [Wed, 29 Mar 2017 01:55:58 +0000 (21:55 -0400)]
Improve Node vs Expr use a bit

Author: Mark Dilger <hornschnorter@gmail.com>

7 years agoCast result of copyObject() to correct type
Peter Eisentraut [Thu, 9 Mar 2017 20:18:59 +0000 (15:18 -0500)]
Cast result of copyObject() to correct type

copyObject() is declared to return void *, which allows easily assigning
the result independent of the input, but it loses all type checking.

If the compiler supports typeof or something similar, cast the result to
the input type.  This creates a greater amount of type safety.  In some
cases, where the result is assigned to a generic type such as Node * or
Expr *, new casts are now necessary, but in general casts are now
unnecessary in the normal case and indicate that something unusual is
happening.

Reviewed-by: Mark Dilger <hornschnorter@gmail.com>
7 years agodoc: Mention --enable-tap-tests in regression test chapter
Peter Eisentraut [Wed, 29 Mar 2017 01:12:30 +0000 (21:12 -0400)]
doc: Mention --enable-tap-tests in regression test chapter

Reported-by: Jeff Janes <jeff.janes@gmail.com>
7 years agoChange 'diag' to 'note' in TAP tests
Peter Eisentraut [Wed, 29 Mar 2017 00:38:06 +0000 (20:38 -0400)]
Change 'diag' to 'note' in TAP tests

Reduce noise from TAP tests by changing 'diag' to 'note', so output only
goes to the test's log file not stdout, unless in verbose mode.  This
also removes the junk on screen when running the TAP tests in parallel.

Author: Craig Ringer <craig@2ndquadrant.com>

7 years agoAllow DSM segments to be created as pinned
Alvaro Herrera [Fri, 24 Mar 2017 22:27:22 +0000 (19:27 -0300)]
Allow DSM segments to be created as pinned

dsm_create and dsm_attach assumed that a current resource owner was
always in place.  Exploration with the API show that this is
inconvenient: sometimes one must create a dummy resowner, create/attach
the DSM, only to pin the mapping later, which is wasteful.  Change
create/attach so that if there is no current resowner, the dsm is
effectively pinned right from the start.

Discussion: https://postgr.es/m/20170324232710.32acsfsvjqfgc6ud@alvherre.pgsql
Reviewed by Thomas Munro.

7 years agoMake new expression eval code reject references to dropped columns.
Tom Lane [Tue, 28 Mar 2017 22:05:03 +0000 (18:05 -0400)]
Make new expression eval code reject references to dropped columns.

Formerly, a Var referencing an already-dropped column was allowed and would
always produce a NULL value.  However, that behavior was implemented in
slot_getattr which the new expression code doesn't use; thus there is now a
risk of returning theoretically-deleted data.  We had regression test cases
that purported to exercise this, but they failed to expose any problem,
apparently because plpgsql filters the dropped column and produces an
output tuple that has a NULL there already.

Ideally the DROP or ALTER attempt in these test cases would get rejected
due to dependency checks; but until that happens, let's modify the behavior
so that we fail the query during executor start.  This was already true for
the related case of a column having changed type underneath us, and there's
no obvious reason why we need to be laxer for dropped columns.

In passing, adjust the error messages in CheckVarSlotCompatibility to
include the composite type name.  In the cases shown in the regression
tests this is always just "record", but it should be more useful in
actual stale-plan cases, where the slot tupdesc would be a table's
tupdesc directly.

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

7 years agoRemove direct uses of ItemPointer.{ip_blkid,ip_posid}
Alvaro Herrera [Tue, 28 Mar 2017 15:52:55 +0000 (12:52 -0300)]
Remove direct uses of ItemPointer.{ip_blkid,ip_posid}

There are no functional changes here; this simply encapsulates knowledge
of the ItemPointerData struct so that a future patch can change things
without more breakage.

All direct users of ip_blkid and ip_posid are changed to use existing
macros ItemPointerGetBlockNumber and ItemPointerGetOffsetNumber
respectively.  For callers where that's inappropriate (because they
Assert that the itempointer is is valid-looking), add
ItemPointerGetBlockNumberNoCheck and ItemPointerGetOffsetNumberNoCheck,
which lack the assertion but are otherwise identical.

Author: Pavan Deolasee
Discussion: https://postgr.es/m/CABOikdNnFon4cJiL=h1mZH3bgUeU+sWHuU4Yr8AB=j3A2p1GiA@mail.gmail.com

7 years agoCorrect grammar in error message
Simon Riggs [Tue, 28 Mar 2017 17:24:39 +0000 (13:24 -0400)]
Correct grammar in error message

"could not generate" rather than "could not generation"
from commit 818fd4a67d610991757b610755e3065fb99d80a5

7 years agoFix ssl tests
Peter Eisentraut [Tue, 28 Mar 2017 17:22:00 +0000 (13:22 -0400)]
Fix ssl tests

facde2a98f0b5f7689b4e30a9e7376e926e733b8 introduced a typo during
rebasing.

7 years agoSuppress implicit-conversion warnings seen with newer clang versions.
Tom Lane [Tue, 28 Mar 2017 17:16:19 +0000 (13:16 -0400)]
Suppress implicit-conversion warnings seen with newer clang versions.

We were assigning values near 255 through "char *" pointers.  On machines
where char is signed, that's not entirely kosher, and it's reasonable
for compilers to warn about it.

A better solution would be to change the pointer type to "unsigned char *",
but that would be vastly more invasive.  For the moment, let's just apply
this simple backpatchable solution.

Aleksander Alekseev

Discussion: https://postgr.es/m/20170220141239.GD12278@e733.localdomain
Discussion: https://postgr.es/m/2839.1490714708@sss.pgh.pa.us

7 years agoAltering default privileges on schemas
Teodor Sigaev [Tue, 28 Mar 2017 15:58:55 +0000 (18:58 +0300)]
Altering default privileges on schemas

Extend ALTER DEFAULT PRIVILEGES command to schemas.

Author: Matheus Oliveira
Reviewed-by: Petr Jelínek, Ashutosh Sharma
https://commitfest.postgresql.org/13/887/

7 years agodblink: Fix error reporting
Peter Eisentraut [Tue, 28 Mar 2017 15:08:38 +0000 (11:08 -0400)]
dblink: Fix error reporting

The conname variable was not initialized in some code paths, resulting
in error reports referring to the "unnamed" connection rather than the
correct connection name.

Author: Rushabh Lathia <rushabh.lathia@gmail.com>

7 years agoCleanup slots during drop database
Simon Riggs [Tue, 28 Mar 2017 14:05:21 +0000 (10:05 -0400)]
Cleanup slots during drop database

Automatically drop all logical replication slots associated with a
database when the database is dropped. Previously we threw an ERROR
if a slot existed. Now we throw ERROR only if a slot is active in
the database being dropped.

Craig Ringer

7 years agoFix Perl code which had broken the Windows build
Peter Eisentraut [Tue, 28 Mar 2017 13:00:59 +0000 (09:00 -0400)]
Fix Perl code which had broken the Windows build

The previous change wanted to avoid modifying $_ in grep, but the code
just made the change in a local variable and then lost it.  Rewrite the
code using a separate map and grep, which is clearer anyway.

Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

7 years agoShow ignored constants as "$N" rather than "?" in pg_stat_statements.
Tom Lane [Tue, 28 Mar 2017 00:14:36 +0000 (20:14 -0400)]
Show ignored constants as "$N" rather than "?" in pg_stat_statements.

The trouble with the original choice here is that "?" is a valid (and
indeed used) operator name, so that you could end up with ambiguous
statement texts like "SELECT ? ? ?".  With this patch, you instead
see "SELECT $1 ? $2", which seems significantly more readable.
The numbers used for this purpose begin after the last actual $N parameter
in the particular query.  The conflict with external parameters has its own
potential for confusion of course, but it was agreed to be an improvement
over the previous behavior.

Lukas Fittl

Discussion: https://postgr.es/m/CAP53PkxeaCuwYmF-A4J5z2-qk5fYFo5_NH3gpXGJJBxv1DMwEw@mail.gmail.com

7 years agoFix uninitialized memory propagation mistakes
Alvaro Herrera [Mon, 27 Mar 2017 17:52:19 +0000 (14:52 -0300)]
Fix uninitialized memory propagation mistakes

Valgrind complains that some uninitialized bytes are being passed around
by the extended statistics code since commit 7b504eb282ca2f, as reported
by Andres Freund.  Silence it.

Tomas Vondra submitted a patch which he verified to fix the complaints
in his machine; however I messed with it a bit before pushing, so any
remaining problems are likely my (Álvaro's) fault.

Author: Tomas Vondra
Discussion: https://postgr.es/m/20170325211031.4xxoptigqxm2emn2@alap3.anarazel.de

7 years agodoc: Improve rendering of notes/cautions using XSL-FO
Peter Eisentraut [Mon, 27 Mar 2017 17:33:36 +0000 (13:33 -0400)]
doc: Improve rendering of notes/cautions using XSL-FO

Center title and put a border around it, like the output that the DSSSL
version gave.

7 years agoStill more code review for single-page hash vacuuming.
Robert Haas [Mon, 27 Mar 2017 16:50:51 +0000 (12:50 -0400)]
Still more code review for single-page hash vacuuming.

Most seriously, fix use of incorrect block ID, per a report from
Jeff Janes that it causes a crash and a diagnosis from Amit Kapila.

Improve consistency between the hash and btree versions of this
code by adding back a PANIC that btree has, and by registering
data in the xlog record in the same way, per complaints from
Jeff Janes and Amit Kapila.

Tidy up some minor cosmetic points, per complaints from Amit
Kapila.

Patch by Ashutosh Sharma, reviewed by Amit Kapila, and tested by
Jeff Janes.

Discussion: http://postgr.es/m/CAMkU=1w-9Qe=Ff1o6bSaXpNO9wqpo7_9GL8_CVhw4BoVVHasqg@mail.gmail.com

7 years agoFsync directory after creating or unlinking file.
Teodor Sigaev [Mon, 27 Mar 2017 16:33:01 +0000 (19:33 +0300)]
Fsync directory after creating or unlinking file.

If file was created/deleted just before powerloss it's possible that
file system will miss that. To prevent it, call fsync() where creating/
unlinkg file is critical.

Author: Michael Paquier
Reviewed-by: Ashutosh Bapat, Takayuki Tsunakawa, me
7 years agoFix thinko in estimate_num_groups
Alvaro Herrera [Mon, 27 Mar 2017 15:52:50 +0000 (12:52 -0300)]
Fix thinko in estimate_num_groups

The code for the reworked n-distinct estimation on commit 7b504eb282 was
written differently in a previous version of the patch, prior to commit;
on rewriting it, we missed updating an initializer.  This caused the
code to (mistakenly) apply a fudge factor even in the case where a
single value is applied, leading to incorrect results.

This means that the 'relvarcount' variable name is now wrong.  Add a
comment to try and make the situation clearer, and remove an incorrect
comment I added.

Problem noticed, and code patch, by Tomas Vondra.  Additional commentary
by Álvaro.

7 years agoImprove performance of find_all_inheritors()
Teodor Sigaev [Mon, 27 Mar 2017 16:07:48 +0000 (19:07 +0300)]
Improve performance of find_all_inheritors()

Previous coding uses three nested loops which obviously were a pain for
large number of table's children. Patch replaces inner loop with
a hashmap.

Author: Aleksander Alekseev
Reviewed-by: me
https://commitfest.postgresql.org/13/1058/

7 years agodoc: Fix oldhtml/old PDF build again
Peter Eisentraut [Mon, 27 Mar 2017 15:57:10 +0000 (11:57 -0400)]
doc: Fix oldhtml/old PDF build again

Commit e259e1f748c7a6d67e307a90d6c27b8ab8b90df8 was faulty and created
some broken output.  This one fixes it better.

7 years agoRework the stats_ext test
Alvaro Herrera [Mon, 27 Mar 2017 15:40:42 +0000 (12:40 -0300)]
Rework the stats_ext test

As suggested by Tom Lane, avoid printing specific estimated cost values,
because they vary across architectures; instead, verify plan shapes (in
this case, HashAggregate vs. GroupAggregate), as we do in other planner
tests.

We can now remove expected/stats_ext_1.out.

Author: Tomas Vondra

7 years agoPL/Python: Add cursor and execute methods to plan object
Peter Eisentraut [Sat, 25 Feb 2017 13:42:25 +0000 (08:42 -0500)]
PL/Python: Add cursor and execute methods to plan object

Instead of

    plan = plpy.prepare(...)
    res = plpy.execute(plan, ...)

you can now write

    plan = plpy.prepare(...)
    res = plan.execute(...)

or even

    res = plpy.prepare(...).execute(...)

and similarly for the cursor() method.

This is more in object oriented style, and makes the hybrid nature of
the existing execute() function less confusing.

Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
7 years agoImprove performance of find_tabstat_entry()/get_tabstat_entry()
Teodor Sigaev [Mon, 27 Mar 2017 15:34:42 +0000 (18:34 +0300)]
Improve performance of find_tabstat_entry()/get_tabstat_entry()

Patch introduces a hash map reloid -> PgStat_TableStatus which improves
performance in case of large number of tables/partitions.

Author: Aleksander Alekseev
Reviewed-by: Andres Freund, Anastasia Lubennikova, Tels, me
https://commitfest.postgresql.org/13/1058/

7 years agoImprove documentation of how NOT NULL works with partitioning.
Robert Haas [Mon, 27 Mar 2017 15:01:33 +0000 (11:01 -0400)]
Improve documentation of how NOT NULL works with partitioning.

Amit Langote

Discussion: http://postgr.es/m/a6f99cdb-21e7-1d65-1381-91f2cfa156e2@lab.ntt.co.jp

7 years agoTidy up the CREATE TABLE documentation for partitioning.
Robert Haas [Mon, 27 Mar 2017 15:00:09 +0000 (11:00 -0400)]
Tidy up the CREATE TABLE documentation for partitioning.

Remove some <note> tags that make this too "loud".  Fix some typos.

Amit Langote, with a few minor corrections by me

Discussion: http://postgr.es/m/a6f99cdb-21e7-1d65-1381-91f2cfa156e2@lab.ntt.co.jp

7 years agoFix improper NULL handling in list partitioning code.
Robert Haas [Mon, 27 Mar 2017 14:51:46 +0000 (10:51 -0400)]
Fix improper NULL handling in list partitioning code.

The previous logic was wrong when the value was NULL but there was
no partition for NULL.

Amit Langote, reviewed by Jeevan Ladhe

Discussion: http://postgr.es/m/d64f8498-70eb-3c88-b56d-c54fd3b0500f@lab.ntt.co.jp

7 years agoAllow ON CONFLICT .. DO NOTHING on a partitioned table.
Robert Haas [Mon, 27 Mar 2017 14:37:29 +0000 (10:37 -0400)]
Allow ON CONFLICT .. DO NOTHING on a partitioned table.

ON CONFLICT .. DO UPDATE still doesn't work, for lack of a way of
enforcing uniqueness across partitions, but we can still allow this
case.

Amit Langote, per discussion with Peter Geoghegan.  Additional
wordsmithing by me.

Discussion: http://postgr.es/m/CAA-aLv7Z4uygtq-Q5CvDi9Y=VZxUyEnuWjL=EwCfOof=L04hgg@mail.gmail.com

7 years agoChange default of log_directory to 'log'
Peter Eisentraut [Mon, 27 Mar 2017 14:34:33 +0000 (10:34 -0400)]
Change default of log_directory to 'log'

The previous default 'pg_log' might have indicated by its "pg_" prefix
that it is an internal system directory.  The new default is more in
line with the typical naming of directories with user-facing log files.
Together with the renaming of pg_clog and pg_xlog, this should clear up
that difference.

Author: Andreas Karlsson <andreas@proxel.se>

7 years agoPass DSA_ALLOC_HUGE when allocating a shared TIDBitmap.
Robert Haas [Mon, 27 Mar 2017 12:30:19 +0000 (08:30 -0400)]
Pass DSA_ALLOC_HUGE when allocating a shared TIDBitmap.

When creating an unshared TIDBitmap, we pass MCXT_ALLOC_HUGE to allow
allocations >1GB, so by analogy we pass DSA_ALLOC_HUGE for a shared
TIDBitmap.

Bug introduced by commit 98e6e89040a0534ca26914c66cae9dd49ef62ad9.
Report by Rafia Sabih, fix by Dilip Kumar, adjusted by me.

Discussion: http://postgr.es/m/CAOGQiiPpSnkuKq+oUK_bvQFg2EPGFPN8RwgxTgBa6HU_kQa3EA@mail.gmail.com

7 years agoClean up Perl code according to perlcritic
Peter Eisentraut [Mon, 27 Mar 2017 02:24:13 +0000 (22:24 -0400)]
Clean up Perl code according to perlcritic

Fix all perlcritic warnings of severity level 5, except in
src/backend/utils/Gen_dummy_probes.pl, which is automatically generated.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
7 years agoAttempt to stabilize grouping sets regression test plans.
Andrew Gierth [Mon, 27 Mar 2017 04:53:26 +0000 (05:53 +0100)]
Attempt to stabilize grouping sets regression test plans.

Per buildfarm members dromedary and arapaima.

7 years agoFix a couple of problems in pg_get_statisticsextdef
Alvaro Herrera [Mon, 27 Mar 2017 03:53:59 +0000 (00:53 -0300)]
Fix a couple of problems in pg_get_statisticsextdef

There was a thinko whereby we tested the wrong tuple after fetching it
from cache; avoid that by using generate_relation_name instead, which is
simpler.  Also, the statistics name was not qualified, so add that.  (It
could be argued that qualification should be conditional on the schema
not being on search path.  We can add that later, but at least this form
is correct.)

Author: David Rowley, Álvaro Herrera
Discussion: https://postgr.es/m/CAKJS1f8RjLeVZJ2+93pdQGuZJeBF-ifsHaFMR-q-6-Z0qxA8cA@mail.gmail.com

7 years agoSupport hashed aggregation with grouping sets.
Andrew Gierth [Mon, 27 Mar 2017 03:20:54 +0000 (04:20 +0100)]
Support hashed aggregation with grouping sets.

This extends the Aggregate node with two new features: HashAggregate
can now run multiple hashtables concurrently, and a new strategy
MixedAggregate populates hashtables while doing sorted grouping.

The planner will now attempt to save as many sorts as possible when
planning grouping sets queries, while not exceeding work_mem for the
estimated combined sizes of all hashtables used.  No SQL-level changes
are required.  There should be no user-visible impact other than the
new EXPLAIN output and possible changes to result ordering when ORDER
BY was not used (which affected a few regression tests).  The
enable_hashagg option is respected.

Author: Andrew Gierth
Reviewers: Mark Dilger, Andres Freund
Discussion: https://postgr.es/m/87vatszyhj.fsf@news-spur.riddles.org.uk

7 years agoFix comment.
Robert Haas [Mon, 27 Mar 2017 02:15:50 +0000 (22:15 -0400)]
Fix comment.

Cut-and-paste led to something silly.

Ashutosh Sharma, reviewed by Amit Kapila and by me

Discussion: http://postgr.es/m/CAE9k0PmUbvQSBY7kwN_OkuqBYyHRXBX-c1ZkuAgR5vgF0GeWzQ@mail.gmail.com

7 years agoShow more processes in pg_stat_activity.
Robert Haas [Mon, 27 Mar 2017 02:02:22 +0000 (22:02 -0400)]
Show more processes in pg_stat_activity.

Previously, auxiliary processes and background workers not connected
to a database (such as the logical replication launcher) weren't
shown.  Include them, so that we can see the associated wait state
information.  Add a new column to identify the processes type, so that
people can filter them out easily using SQL if they wish.

Before this patch was written, there was discussion about whether we
should expose this information in a separate view, so as to avoid
contaminating pg_stat_activity with things people might not want to
see.  But putting everything in pg_stat_activity was a more popular
choice, so that's what the patch does.

Kuntal Ghosh, reviewed by Amit Langote and Michael Paquier.  Some
revisions and bug fixes by me.

Discussion: http://postgr.es/m/CA+TgmoYES5nhkEGw9nZXU8_FhA8XEm8NTm3-SO+3ML1B81Hkww@mail.gmail.com

7 years agoImprove performance of ExecEvalWholeRowVar.
Tom Lane [Sun, 26 Mar 2017 23:14:47 +0000 (19:14 -0400)]
Improve performance of ExecEvalWholeRowVar.

In commit b8d7f053c, we needed to fix ExecEvalWholeRowVar to not change
the state of the slot it's copying.  The initial quick hack at that
required two rounds of tuple construction, which is not very nice.
To fix, add another primitive to tuptoaster.c that does precisely what
we need.  (I initially tried to do this by refactoring one of the
existing functions into two pieces; but it looked like that might hurt
performance for the existing case, and the amount of code that could
be shared is not very large, so I gave up on that.)

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

7 years agoFix cpluspluscheck warning
Peter Eisentraut [Sun, 26 Mar 2017 22:31:05 +0000 (18:31 -0400)]
Fix cpluspluscheck warning

Structure tag cannot be the same as a typedef that is a pointer to that
struct.

7 years agoUse ExecPrepareExpr in place of ExecPrepareCheck where appropriate.
Tom Lane [Sun, 26 Mar 2017 22:14:03 +0000 (18:14 -0400)]
Use ExecPrepareExpr in place of ExecPrepareCheck where appropriate.

Change one more place where ExecInitCheck/ExecPrepareCheck's insistence
on getting implicit-AND-format quals wasn't really helpful, because the
caller had to do make_ands_implicit() for no reason that it cared about.
Using ExecPrepareExpr directly simplifies the code and saves cycles.

The only remaining use of these functions is to process
resultRelInfo->ri_PartitionCheck quals.  However, implicit-AND format
does seem to be what we want for that, so leave it alone.

7 years agoFix typos in logical replication support for initial data copy.
Tom Lane [Sun, 26 Mar 2017 21:44:35 +0000 (17:44 -0400)]
Fix typos in logical replication support for initial data copy.

Fix an incorrect assert condition (noted by Coverity), and spell the new
name of the function correctly.  Typos introduced in commit 7c4f52409.

Michael Paquier

7 years agoFix unportable disregard of alignment requirements in RADIUS code.
Tom Lane [Sun, 26 Mar 2017 21:35:35 +0000 (17:35 -0400)]
Fix unportable disregard of alignment requirements in RADIUS code.

The compiler is entitled to store a char[] local variable with no
particular alignment requirement.  Our RADIUS code cavalierly took such
a local variable and cast its address to a struct type that does have
alignment requirements.  On an alignment-picky machine this would lead
to bus errors.  To fix, declare the local variable honestly, and then
cast its address to char * for use in the I/O calls.

Given the lack of field complaints, there must be very few if any
people affected; but nonetheless this is a clear portability issue,
so back-patch to all supported branches.

Noted while looking at a Coverity complaint in the same code.

7 years agoFix some minor resource leaks in PerformRadiusTransaction().
Tom Lane [Sun, 26 Mar 2017 21:02:38 +0000 (17:02 -0400)]
Fix some minor resource leaks in PerformRadiusTransaction().

Failure to free serveraddrs pointed out by Coverity, failure to close
socket noted by code-reading.  These bugs seem to be quite old, but
given the low probability of taking these error-exit paths and the
minimal consequences of the leaks (since the process would presumably
exit shortly anyway), it doesn't seem worth back-patching.

Michael Paquier and Tom Lane

7 years agoImprove implementation of EEOP_BOOLTEST_* opcodes.
Tom Lane [Sun, 26 Mar 2017 19:57:02 +0000 (15:57 -0400)]
Improve implementation of EEOP_BOOLTEST_* opcodes.

Both Andres and I were happy with "*op->resvalue = *op->resvalue;",
but Coverity isn't; and it has a point, because some compilers might
not be smart enough to elide that.  So remove it.  In passing, also
avoid doing unnecessary assignments to *op->resnull when it's already
known to have the right value.

7 years agodoc: Fix oldhtml/old PDF build
Peter Eisentraut [Sun, 26 Mar 2017 19:03:27 +0000 (15:03 -0400)]
doc: Fix oldhtml/old PDF build

"xref to REFSECT1 unsupported" with the DSSSL stylesheets.

Reported-by: Devrim Gündüz <devrim@gunduz.org>
7 years agodoc: Clean up bibliography rendering for XSLT
Peter Eisentraut [Sun, 26 Mar 2017 18:54:56 +0000 (14:54 -0400)]
doc: Clean up bibliography rendering for XSLT

In the DSSSL stylesheets, we had an extensive customization of the
bibliography rendering.  Since the bibliography isn't that used much, it
doesn't seem worth doing an elaborate porting of that to XSLT.  So this
just moves some things around, removes some unused things, and does some
minimal XSLT stylesheet customizations to make things look clean.

7 years agoUpdate some obsolete comments.
Tom Lane [Sun, 26 Mar 2017 15:36:46 +0000 (11:36 -0400)]
Update some obsolete comments.

Fix a few stray references to expression eval functions that don't
exist anymore or don't take the same input representation they used to.

7 years agoAdd missing break
Alvaro Herrera [Sun, 26 Mar 2017 14:31:23 +0000 (11:31 -0300)]
Add missing break

Noticed by Coverity

7 years agoBlindly attempt to fix sepgsql tests #2.
Andres Freund [Sun, 26 Mar 2017 03:54:23 +0000 (20:54 -0700)]
Blindly attempt to fix sepgsql tests #2.

7 years agoBlindly attempt to fix sepgsql tests.
Andres Freund [Sun, 26 Mar 2017 03:35:55 +0000 (20:35 -0700)]
Blindly attempt to fix sepgsql tests.

Due to b8d7f053c5c some permission checks are now happening even on
empty tables, and some of the checks move around.

Discussion: https://postgr.es/m/95bdb608-093c-160f-c6be-983a36ccd7f9@joeconway.com

7 years agoRemove unreachable code in expression evaluation.
Andres Freund [Sat, 25 Mar 2017 22:32:01 +0000 (15:32 -0700)]
Remove unreachable code in expression evaluation.

The previous code still contained expression evaluation time support
for CaseExprs without a defresult.  But transformCaseExpr() creates a
default expression if necessary.

Author: Andres Freund
Discussion: https://postgr.es/m/4834.1490480275@sss.pgh.pa.us

7 years agogit rm execQual.c
Tom Lane [Sat, 25 Mar 2017 22:22:16 +0000 (18:22 -0400)]
git rm execQual.c

Should have been in commit b8d7f053c5c2bf2a7e8734fe3327f6a8bc711755,
but passing the patch back and forth as a patch seems to have dropped
that metadata.

7 years agoFaster expression evaluation and targetlist projection.
Andres Freund [Tue, 14 Mar 2017 22:45:36 +0000 (15:45 -0700)]
Faster expression evaluation and targetlist projection.

This replaces the old, recursive tree-walk based evaluation, with
non-recursive, opcode dispatch based, expression evaluation.
Projection is now implemented as part of expression evaluation.

This both leads to significant performance improvements, and makes
future just-in-time compilation of expressions easier.

The speed gains primarily come from:
- non-recursive implementation reduces stack usage / overhead
- simple sub-expressions are implemented with a single jump, without
  function calls
- sharing some state between different sub-expressions
- reduced amount of indirect/hard to predict memory accesses by laying
  out operation metadata sequentially; including the avoidance of
  nearly all of the previously used linked lists
- more code has been moved to expression initialization, avoiding
  constant re-checks at evaluation time

Future just-in-time compilation (JIT) has become easier, as
demonstrated by released patches intended to be merged in a later
release, for primarily two reasons: Firstly, due to a stricter split
between expression initialization and evaluation, less code has to be
handled by the JIT. Secondly, due to the non-recursive nature of the
generated "instructions", less performance-critical code-paths can
easily be shared between interpreted and compiled evaluation.

The new framework allows for significant future optimizations. E.g.:
- basic infrastructure for to later reduce the per executor-startup
  overhead of expression evaluation, by caching state in prepared
  statements.  That'd be helpful in OLTPish scenarios where
  initialization overhead is measurable.
- optimizing the generated "code". A number of proposals for potential
  work has already been made.
- optimizing the interpreter. Similarly a number of proposals have
  been made here too.

The move of logic into the expression initialization step leads to some
backward-incompatible changes:
- Function permission checks are now done during expression
  initialization, whereas previously they were done during
  execution. In edge cases this can lead to errors being raised that
  previously wouldn't have been, e.g. a NULL array being coerced to a
  different array type previously didn't perform checks.
- The set of domain constraints to be checked, is now evaluated once
  during expression initialization, previously it was re-built
  every time a domain check was evaluated. For normal queries this
  doesn't change much, but e.g. for plpgsql functions, which caches
  ExprStates, the old set could stick around longer.  The behavior
  around might still change.

Author: Andres Freund, with significant changes by Tom Lane,
changes by Heikki Linnakangas
Reviewed-By: Tom Lane, Heikki Linnakangas
Discussion: https://postgr.es/m/20161206034955.bh33paeralxbtluv@alap3.anarazel.de

7 years agoRe-adhere to policy of no more than 20 tests per parallel group.
Tom Lane [Sat, 25 Mar 2017 21:32:13 +0000 (17:32 -0400)]
Re-adhere to policy of no more than 20 tests per parallel group.

As explained at the head of parallel_schedule, we place an arbitrary limit
of 20 test cases per parallel group.  Commit c7a9fa399 overlooked this.

Least messy solution seems to be to move the "comments" test to the next
group, since it doesn't really belong in a group of datatype tests anyway.

7 years agoRemember to drop roles created by regression tests.
Tom Lane [Sat, 25 Mar 2017 21:25:28 +0000 (17:25 -0400)]
Remember to drop roles created by regression tests.

Commit e3920ac82 created "regress_subscription_user2" in subscription.sql,
but forgot to drop it, causing the regression tests to fail if run twice
without re-initdb'ing.

7 years agoAdd cleanup to new test cases
Peter Eisentraut [Sat, 25 Mar 2017 15:11:43 +0000 (11:11 -0400)]
Add cleanup to new test cases

7 years agoReport catalog_xmin separately in hot_standby_feedback
Simon Riggs [Sat, 25 Mar 2017 14:07:27 +0000 (14:07 +0000)]
Report catalog_xmin separately in hot_standby_feedback

If the upstream walsender is using a physical replication slot, store the
catalog_xmin in the slot's catalog_xmin field. If the upstream doesn't use a
slot and has only a PGPROC entry behaviour doesn't change, as we store the
combined xmin and catalog_xmin in the PGPROC entry.

Author: Craig Ringer

7 years agoAdd missing break
Peter Eisentraut [Sat, 25 Mar 2017 04:50:05 +0000 (00:50 -0400)]
Add missing break

Reported-by: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
7 years agopsql: Add missing schema qualification
Peter Eisentraut [Sat, 25 Mar 2017 04:49:08 +0000 (00:49 -0400)]
psql: Add missing schema qualification

7 years agoFix locale pointer use in WIN32 code path
Peter Eisentraut [Sat, 25 Mar 2017 04:38:12 +0000 (00:38 -0400)]
Fix locale pointer use in WIN32 code path

Author: David Rowley <david.rowley@2ndquadrant.com>

7 years agoRemove ICU tests from default run
Peter Eisentraut [Sat, 25 Mar 2017 04:28:28 +0000 (00:28 -0400)]
Remove ICU tests from default run

These tests require the test database to be in UTF8 encoding.  Until
there is a better solution, take them out of the default test set and
treat them like the existing collate.linux.utf8 test, meaning it has to
be selected manually.

7 years agoFix recovery test hang
Peter Eisentraut [Sat, 25 Mar 2017 04:10:57 +0000 (00:10 -0400)]
Fix recovery test hang

The test would hang if a sufficient ~/.psqlrc was present.  Fix by using
psql -X.

7 years agoAdd COMMENT and SECURITY LABEL support for publications and subscriptions
Peter Eisentraut [Sat, 25 Mar 2017 03:25:24 +0000 (23:25 -0400)]
Add COMMENT and SECURITY LABEL support for publications and subscriptions

7 years agoMake header self-contained
Peter Eisentraut [Sat, 25 Mar 2017 03:36:10 +0000 (23:36 -0400)]
Make header self-contained

Add necessary include files for things used in the header.

7 years agoAdd more subscription DDL tests
Peter Eisentraut [Sat, 25 Mar 2017 01:48:05 +0000 (21:48 -0400)]
Add more subscription DDL tests

Add more tests for various variants of subscription DDL commands, based
on code coverage report.  Fix a small bug discovered by that.

7 years agoFix typo in comment
Alvaro Herrera [Fri, 24 Mar 2017 20:20:55 +0000 (17:20 -0300)]
Fix typo in comment

7 years agoFix stats_ext test in 32 bit machines
Alvaro Herrera [Fri, 24 Mar 2017 19:14:34 +0000 (16:14 -0300)]
Fix stats_ext test in 32 bit machines

Because tuple packing is different (because of the MAXALIGN difference),
the expected costs of a seqscan is different.

The commonly used trick of eliding costs in EXPLAIN output (COSTS OFF)
would make the tests completely pointless.  Instead, add an alternative
expected file.

7 years agoCheck that published table exists on subscriber
Peter Eisentraut [Fri, 24 Mar 2017 18:44:11 +0000 (14:44 -0400)]
Check that published table exists on subscriber

Author: Petr Jelinek <pjmodos@pjmodos.net>

7 years agoImprove access to parallel query from procedural languages.
Robert Haas [Fri, 24 Mar 2017 18:46:33 +0000 (14:46 -0400)]
Improve access to parallel query from procedural languages.

In SQL, the ability to use parallel query was previous contingent on
fcache->readonly_func, which is only set for non-volatile functions;
but the volatility of a function has no bearing on whether queries
inside it can use parallelism.  Remove that condition.

SPI_execute and SPI_execute_with_args always run the plan just once,
though not necessarily to completion.  Given the changes in commit
691b8d59281b5177f16fe80858df921f77a8e955, it's sensible to pass
CURSOR_OPT_PARALLEL_OK here, so do that.  This improves access to
parallelism for any caller that uses these functions to execute
queries.  Such callers include plperl, plpython, pltcl, and plpgsql,
though it's not the case that they all use these functions
exclusively.

In plpgsql, allow parallel query for plain SELECT queries (as
opposed to PERFORM, which already worked) and for plain expressions
(which probably won't go through the executor at all, because they
will likely be simple expressions, but if they do then this helps).

Rafia Sabih and Robert Haas, reviewed by Dilip Kumar and Amit Kapila

Discussion: http://postgr.es/m/CAOGQiiMfJ+4SQwgG=6CVHWoisiU0+7jtXSuiyXBM3y=A=eJzmg@mail.gmail.com

7 years agoFix use-after-free bug
Alvaro Herrera [Fri, 24 Mar 2017 18:43:03 +0000 (15:43 -0300)]
Fix use-after-free bug

Detected by buildfarm member prion

7 years agoReverting 42b4b0b2413b9b472aaf2112a3bbfd80a6ab4dc5
Simon Riggs [Fri, 24 Mar 2017 17:56:17 +0000 (17:56 +0000)]
Reverting 42b4b0b2413b9b472aaf2112a3bbfd80a6ab4dc5

Buildfarm issues and other reported issues

7 years agoMake VACUUM VERBOSE report the number of skipped frozen pages.
Fujii Masao [Fri, 24 Mar 2017 17:39:44 +0000 (02:39 +0900)]
Make VACUUM VERBOSE report the number of skipped frozen pages.

Previously manual VACUUM did not report the number of skipped frozen
pages even when VERBOSE option is specified. But this information is
helpful to monitor the VACUUM activity, and also autovacuum reports that
number in the log file when the condition of log_autovacuum_min_duration
is met.

This commit changes VACUUM VERBOSE so that it reports the number
of frozen pages that it skips.

Author: Masahiko Sawada
Reviewed-by: Yugo Nagata and Jim Nasby
Discussion: http://postgr.es/m/CAD21AoDZQKCxo0L39Mrq08cONNkXQKXuh=2DP1Q8ebmt35SoaA@mail.gmail.com

7 years agoImplement multivariate n-distinct coefficients
Alvaro Herrera [Fri, 24 Mar 2017 17:06:10 +0000 (14:06 -0300)]
Implement multivariate n-distinct coefficients

Add support for explicitly declared statistic objects (CREATE
STATISTICS), allowing collection of statistics on more complex
combinations that individual table columns.  Companion commands DROP
STATISTICS and ALTER STATISTICS ... OWNER TO / SET SCHEMA / RENAME are
added too.  All this DDL has been designed so that more statistic types
can be added later on, such as multivariate most-common-values and
multivariate histograms between columns of a single table, leaving room
for permitting columns on multiple tables, too, as well as expressions.

This commit only adds support for collection of n-distinct coefficient
on user-specified sets of columns in a single table.  This is useful to
estimate number of distinct groups in GROUP BY and DISTINCT clauses;
estimation errors there can cause over-allocation of memory in hashed
aggregates, for instance, so it's a worthwhile problem to solve.  A new
special pseudo-type pg_ndistinct is used.

(num-distinct estimation was deemed sufficiently useful by itself that
this is worthwhile even if no further statistic types are added
immediately; so much so that another version of essentially the same
functionality was submitted by Kyotaro Horiguchi:
https://postgr.es/m/20150828.173334.114731693.horiguchi.kyotaro@lab.ntt.co.jp
though this commit does not use that code.)

Author: Tomas Vondra.  Some code rework by Álvaro.
Reviewed-by: Dean Rasheed, David Rowley, Kyotaro Horiguchi, Jeff Janes,
    Ideriha Takeshi
Discussion: https://postgr.es/m/543AFA15.4080608@fuzzy.cz
    https://postgr.es/m/20170320190220.ixlaueanxegqd5gr@alvherre.pgsql

7 years agoplpgsql: Don't generate parallel plans for RETURN QUERY.
Robert Haas [Fri, 24 Mar 2017 16:30:39 +0000 (12:30 -0400)]
plpgsql: Don't generate parallel plans for RETURN QUERY.

Commit 7aea8e4f2daa4b39ca9d1309a0c4aadb0f7ed81b allowed a parallel
plan to be generated when for a RETURN QUERY or RETURN QUERY EXECUTE
statement in a PL/pgsql block, but that's a bad idea because plplgsql
asks the executor for 50 rows at a time.  That means that we'll always
be running serially a plan that was intended for parallel execution,
which is not a good idea.  Fix by not requesting a parallel plan from
the outset.

Per discussion, back-patch to 9.6.  There is a slight risk that, due
to optimizer error, somebody could have a case where the parallel plan
executed serially is actually faster than the supposedly-best serial
plan, but the consensus seems to be that that's not sufficient
justification for leaving 9.6 unpatched.

Discussion: http://postgr.es/m/CA+TgmoZ_ZuH+auEeeWnmtorPsgc_SmP+XWbDsJ+cWvWBSjNwDQ@mail.gmail.com
Discussion: http://postgr.es/m/CA+TgmobXEhvHbJtWDuPZM9bVSLiTj-kShxQJ2uM5GPDze9fRYA@mail.gmail.com

7 years agoAdd a txid_status function.
Robert Haas [Fri, 24 Mar 2017 16:00:53 +0000 (12:00 -0400)]
Add a txid_status function.

If your connection to the database server is lost while a COMMIT is
in progress, it may be difficult to figure out whether the COMMIT was
successful or not.  This function will tell you, provided that you
don't wait too long to ask.  It may be useful in other situations,
too.

Craig Ringer, reviewed by Simon Riggs and by me

Discussion: http://postgr.es/m/CAMsr+YHQiWNEi0daCTboS40T+V5s_+dst3PYv_8v2wNVH+Xx4g@mail.gmail.com

7 years agoAvoid SnapshotResetXmin() during AtEOXact_Snapshot()
Simon Riggs [Fri, 24 Mar 2017 14:20:59 +0000 (14:20 +0000)]
Avoid SnapshotResetXmin() during AtEOXact_Snapshot()

For normal commits and aborts we already reset PgXact->xmin
Avoiding touching highly contented shmem improves concurrent
performance.

Simon Riggs

Discussion: CANP8+jJdXE9b+b9F8CQT-LuxxO0PBCB-SZFfMVAdp+akqo4zfg@mail.gmail.com

7 years agoHandle empty result set in libpqrcv_exec
Peter Eisentraut [Fri, 24 Mar 2017 12:41:32 +0000 (08:41 -0400)]
Handle empty result set in libpqrcv_exec

Always return tupleslot and tupledesc from libpqrcv_exec.  This avoids
requiring callers to handle that separately.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reported-by: Michael Banck <michael.banck@credativ.de>
7 years agoAllow SCRAM authentication, when pg_hba.conf says 'md5'.
Heikki Linnakangas [Fri, 24 Mar 2017 11:32:21 +0000 (13:32 +0200)]
Allow SCRAM authentication, when pg_hba.conf says 'md5'.

If a user has a SCRAM verifier in pg_authid.rolpassword, there's no reason
we cannot attempt to perform SCRAM authentication instead of MD5. The worst
that can happen is that the client doesn't support SCRAM, and the
authentication will fail. But previously, it would fail for sure, because
we would not even try. SCRAM is strictly more secure than MD5, so there's
no harm in trying it. This allows for a more graceful transition from MD5
passwords to SCRAM, as user passwords can be changed to SCRAM verifiers
incrementally, without changing pg_hba.conf.

Refactor the code in auth.c to support that better. Notably, we now have to
look up the user's pg_authid entry before sending the password challenge,
also when performing MD5 authentication. Also simplify the concept of a
"doomed" authentication. Previously, if a user had a password, but it had
expired, we still performed SCRAM authentication (but always returned error
at the end) using the salt and iteration count from the expired password.
Now we construct a fake salt, like we do when the user doesn't have a
password or doesn't exist at all. That simplifies get_role_password(), and
we can don't need to distinguish the  "user has expired password", and
"user does not exist" cases in auth.c.

On second thoughts, also rename uaSASL to uaSCRAM. It refers to the
mechanism specified in pg_hba.conf, and while we use SASL for SCRAM
authentication at the protocol level, the mechanism should be called SCRAM,
not SASL. As a comparison, we have uaLDAP, even though it looks like the
plain 'password' authentication at the protocol level.

Discussion: https://www.postgresql.org/message-id/6425.1489506016@sss.pgh.pa.us
Reviewed-by: Michael Paquier
7 years agoFix backup canceling
Teodor Sigaev [Fri, 24 Mar 2017 10:53:40 +0000 (13:53 +0300)]
Fix backup canceling

Assert-enabled build crashes but without asserts it works by wrong way:
it may not reset forcing full page write and preventing from starting
exclusive backup with the same name as cancelled.
Patch replaces pair of booleans
nonexclusive_backup_running/exclusive_backup_running to single enum to
correctly describe backup state.

Backpatch to 9.6 where bug was introduced

Reported-by: David Steele
Authors: Michael Paquier, David Steele
Reviewed-by: Anastasia Lubennikova
https://commitfest.postgresql.org/13/1068/

7 years agoAvoid syntax error on platforms that have neither LOCALE_T nor ICU.
Tom Lane [Fri, 24 Mar 2017 03:18:52 +0000 (23:18 -0400)]
Avoid syntax error on platforms that have neither LOCALE_T nor ICU.

Buildfarm member anole sees this union as empty, and doesn't like it.

7 years agodoc: add missing closing 'sect3' tag for ICU patch
Bruce Momjian [Thu, 23 Mar 2017 20:59:24 +0000 (16:59 -0400)]
doc:  add missing closing 'sect3' tag for ICU patch

7 years agoAdd ICU_FLAGS to one more place
Peter Eisentraut [Thu, 23 Mar 2017 20:53:10 +0000 (16:53 -0400)]
Add ICU_FLAGS to one more place

Reported-by: Thomas Munro <thomas.munro@enterprisedb.com>
7 years agoFix crash in ICU patch
Peter Eisentraut [Thu, 23 Mar 2017 20:31:39 +0000 (16:31 -0400)]
Fix crash in ICU patch

This only happened with single-byte encodings.

7 years agoFix enum definition.
Robert Haas [Thu, 23 Mar 2017 20:10:43 +0000 (16:10 -0400)]
Fix enum definition.

Commit 249cf070e36721a65be74838c53acf8249faf935 assigned to one of
the labels in the middle the value that should have been assigned
to the first member of the enum.  Rushabh's patch didn't have that
defect as submitted, but I managed to mess it up while editing.
Repair.

7 years agoICU support
Peter Eisentraut [Thu, 23 Mar 2017 19:25:34 +0000 (15:25 -0400)]
ICU support

Add a column collprovider to pg_collation that determines which library
provides the collation data.  The existing choices are default and libc,
and this adds an icu choice, which uses the ICU4C library.

The pg_locale_t type is changed to a union that contains the
provider-specific locale handles.  Users of locale information are
changed to look into that struct for the appropriate handle to use.

Also add a collversion column that records the version of the collation
when it is created, and check at run time whether it is still the same.
This detects potentially incompatible library upgrades that can corrupt
indexes and other structures.  This is currently only supported by
ICU-provided collations.

initdb initializes the default collation set as before from the `locale
-a` output but also adds all available ICU locales with a "-x-icu"
appended.

Currently, ICU-provided collations can only be explicitly named
collations.  The global database locales are still always libc-provided.

ICU support is enabled by configure --with-icu.

Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
7 years agoTrack the oldest XID that can be safely looked up in CLOG.
Robert Haas [Thu, 23 Mar 2017 18:08:23 +0000 (14:08 -0400)]
Track the oldest XID that can be safely looked up in CLOG.

This provides infrastructure for looking up arbitrary, user-supplied
XIDs without a risk of scary-looking failures from within the clog
module.  Normally, the oldest XID that can be safely looked up in CLOG
is the same as the oldest XID that can reused without causing
wraparound, and the latter is already tracked.  However, while
truncation is in progress, the values are different, so we must
keep track of them separately.

Craig Ringer, reviewed by Simon Riggs and by me.

Discussion: http://postgr.es/m/CAMsr+YHQiWNEi0daCTboS40T+V5s_+dst3PYv_8v2wNVH+Xx4g@mail.gmail.com

7 years agoRemove createlang and droplang
Peter Eisentraut [Thu, 23 Mar 2017 18:16:45 +0000 (14:16 -0400)]
Remove createlang and droplang

They have been deprecated since PostgreSQL 9.1.

Reviewed-by: Magnus Hagander <magnus@hagander.net>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
7 years agoAllow for parallel execution whenever ExecutorRun() is done only once.
Robert Haas [Thu, 23 Mar 2017 17:05:48 +0000 (13:05 -0400)]
Allow for parallel execution whenever ExecutorRun() is done only once.

Previously, it was unsafe to execute a plan in parallel if
ExecutorRun() might be called with a non-zero row count.  However,
it's quite easy to fix things up so that we can support that case,
provided that it is known that we will never call ExecutorRun() a
second time for the same QueryDesc.  Add infrastructure to signal
this, and cross-checks to make sure that a caller who claims this is
true doesn't later reneg.

While that pattern never happens with queries received directly from a
client -- there's no way to know whether multiple Execute messages
will be sent unless the first one requests all the rows -- it's pretty
common for queries originating from procedural languages, which often
limit the result to a single tuple or to a user-specified number of
tuples.

This commit doesn't actually enable parallelism in any additional
cases, because currently none of the places that would be able to
benefit from this infrastructure pass CURSOR_OPT_PARALLEL_OK in the
first place, but it makes it much more palatable to pass
CURSOR_OPT_PARALLEL_OK in places where we currently don't, because it
eliminates some cases where we'd end up having to run the parallel
plan serially.

Patch by me, based on some ideas from Rafia Sabih and corrected by
Rafia Sabih based on feedback from Dilip Kumar and myself.

Discussion: http://postgr.es/m/CA+TgmobXEhvHbJtWDuPZM9bVSLiTj-kShxQJ2uM5GPDze9fRYA@mail.gmail.com

7 years agoReduce page locking in GIN vacuum
Teodor Sigaev [Thu, 23 Mar 2017 16:38:47 +0000 (19:38 +0300)]
Reduce page locking in GIN vacuum

GIN vacuum during cleaning posting tree can lock this whole tree for a long
time with by holding LockBufferForCleanup() on root. Patch changes it with
two ways: first, cleanup lock will be taken only if there is an empty page
(which should be deleted) and, second, it tries to lock only subtree, not the
whole posting tree.

Author: Andrey Borodin with minor editorization by me
Reviewed-by: Jeff Davis, me
https://commitfest.postgresql.org/13/896/