]> granicus.if.org Git - postgresql/log
postgresql
8 years agoAdd BSD authentication method.
Tom Lane [Fri, 8 Apr 2016 17:51:54 +0000 (13:51 -0400)]
Add BSD authentication method.

Create a "bsd" auth method that works the same as "password" so far as
clients are concerned, but calls the BSD Authentication service to
check the password.  This is currently only available on OpenBSD.

Marisa Emerson, reviewed by Thomas Munro

8 years agoAdd combine functions for various floating-point aggregates.
Robert Haas [Fri, 8 Apr 2016 17:44:50 +0000 (13:44 -0400)]
Add combine functions for various floating-point aggregates.

This allows parallel aggregation to use them.  It may seem surprising
that we use float8_combine for both float4_accum and float8_accum
transition functions, but that's because those functions differ only
in the type of the non-transition-state argument.

Haribabu Kommi, reviewed by David Rowley and Tomas Vondra

8 years agoFix output of regression test of contrib/tsearch2
Teodor Sigaev [Fri, 8 Apr 2016 17:37:12 +0000 (20:37 +0300)]
Fix output of regression test of contrib/tsearch2

Just forget to add in 1ec4c7c055ca045c5df6352a4cdacd9aa778e598

8 years agoRestore original tsquery operation numbering.
Teodor Sigaev [Fri, 8 Apr 2016 17:11:30 +0000 (20:11 +0300)]
Restore original tsquery operation numbering.

As noticed by Tom Lane changing operation's number in commit
bb140506df605fab58f48926ee1db1f80bdafb59 causes on-disk format incompatibility.
Revert to previous numbering, that is reason to add special array to store
priorities of operation. Also it reverts order of tsquery to previous.

Author: Dmitry Ivanov

8 years agoSilence warning from modern perl about unescaped braces
Andrew Dunstan [Fri, 8 Apr 2016 16:50:30 +0000 (12:50 -0400)]
Silence warning from modern perl about unescaped braces

8 years agoCREATE INDEX ... INCLUDING (column[, ...])
Teodor Sigaev [Fri, 8 Apr 2016 16:31:49 +0000 (19:31 +0300)]
CREATE INDEX ... INCLUDING (column[, ...])

Now indexes (but only B-tree for now) can contain "extra" column(s) which
doesn't participate in index structure, they are just stored in leaf
tuples. It allows to use index only scan by using single index instead
of two or more indexes.

Author: Anastasia Lubennikova with minor editorializing by me
Reviewers: David Rowley, Peter Geoghegan, Jeff Janes

8 years agoReplace printf format %i by %d
Peter Eisentraut [Fri, 8 Apr 2016 16:40:15 +0000 (12:40 -0400)]
Replace printf format %i by %d

see also ce8d7bb6440710058503d213b2aafcdf56a5b481

8 years agoTurn down MSVC compiler verbosity
Andrew Dunstan [Fri, 8 Apr 2016 16:25:10 +0000 (12:25 -0400)]
Turn down MSVC compiler verbosity

Most of what is produced by the detailed verbosity level is of no
interest at all, so switch to the normal level for more usable output.

Christian Ullrich

Backpatch to all live branches

8 years agoFix printf format
Peter Eisentraut [Fri, 8 Apr 2016 16:31:44 +0000 (12:31 -0400)]
Fix printf format

8 years agoFix multiple bugs in tablespace symlink removal.
Tom Lane [Fri, 8 Apr 2016 16:31:42 +0000 (12:31 -0400)]
Fix multiple bugs in tablespace symlink removal.

Don't try to examine S_ISLNK(st.st_mode) after a failed lstat().
It's undefined.

Also, if the lstat() reported ENOENT, we do not wish that to be a hard
error, but the code might nonetheless treat it as one (giving an entirely
misleading error message, too) depending on luck-of-the-draw as to what
S_ISLNK() returned.

Don't throw error for ENOENT from rmdir(), either.  (We're not really
expecting ENOENT because we just stat'd the file successfully; but
if we're going to allow ENOENT in the symlink code path, surely the
directory code path should too.)

Generate an appropriate errcode for its-the-wrong-type-of-file complaints.
(ERRCODE_SYSTEM_ERROR doesn't seem appropriate, and failing to write
errcode() around it certainly doesn't work, and not writing an errcode
at all is not per project policy.)

Valgrind noticed the undefined S_ISLNK result; the other problems emerged
while reading the code in the area.

All of this appears to have been introduced in 8f15f74a44f68f9c.
Back-patch to 9.5 where that commit appeared.

8 years agoDocument which aggregates support partial mode.
Robert Haas [Fri, 8 Apr 2016 16:09:58 +0000 (12:09 -0400)]
Document which aggregates support partial mode.

David Rowley, reviewed by Tomas Vondra

8 years agoEnhanced custom error in PLPythonu
Teodor Sigaev [Fri, 8 Apr 2016 15:30:25 +0000 (18:30 +0300)]
Enhanced custom error in PLPythonu

Patch adds a new, more rich,  way to emit error message or exception from
PL/Pythonu code.

Author: Pavel Stehule
Reviewers: Catalin Iacob, Peter Eisentraut, Jim Nasby

8 years agoIncrease maximum number of clog buffers.
Andres Freund [Fri, 8 Apr 2016 15:18:52 +0000 (08:18 -0700)]
Increase maximum number of clog buffers.

Benchmarking has shown that the current number of clog buffers limits
scalability. We've previously increased the number in 33aaa139, but
that's not sufficient with a large number of clients.

We've benchmarked the cost of increasing the limit by benchmarking worst
case scenarios; testing showed that 128 buffers don't cause a
regression, even in contrived scenarios, whereas 256 does

There are a number of more complex patches flying around to address
various clog scalability problems, but this is simple enough that we can
get it into 9.6; and is beneficial even after those patches have been
applied.

It is a bit unsatisfactory to increase this in small steps every few
releases, but a better solution seems to require a rewrite of slru.c;
not something done quickly.

Author: Amit Kapila and Andres Freund
Discussion: CAA4eK1+-=18HOrdqtLXqOMwZDbC_15WTyHiFruz7BvVArZPaAw@mail.gmail.com

8 years agoAdd a 'parallel_degree' reloption.
Robert Haas [Fri, 8 Apr 2016 15:14:56 +0000 (11:14 -0400)]
Add a 'parallel_degree' reloption.

The code that estimates what parallel degree should be uesd for the
scan of a relation is currently rather stupid, so add a parallel_degree
reloption that can be used to override the planner's rather limited
judgement.

Julien Rouhaud, reviewed by David Rowley, James Sewell, Amit Kapila,
and me.  Some further hacking by me.

8 years agoAttempt to fix breakage due to declaration following code.
Robert Haas [Fri, 8 Apr 2016 14:52:56 +0000 (10:52 -0400)]
Attempt to fix breakage due to declaration following code.

Per Tom Lane and the buildfarm.

8 years agoSet PAM_RHOST item for PAM authentication
Peter Eisentraut [Fri, 8 Apr 2016 14:45:16 +0000 (10:45 -0400)]
Set PAM_RHOST item for PAM authentication

The PAM_RHOST item is set to the remote IP address or host name and can
be used by PAM modules.  A pg_hba.conf option is provided to choose
between IP address and resolved host name.

From: Grzegorz Sampolski <grzsmp@gmail.com>
Reviewed-by: Haribabu Kommi <kommi.haribabu@gmail.com>
8 years agoRename comparePos() to compareWordEntryPos()
Teodor Sigaev [Fri, 8 Apr 2016 09:02:45 +0000 (12:02 +0300)]
Rename comparePos() to compareWordEntryPos()

Rename comparePos() to compareWordEntryPos() to prevent export of too
generic name.

Per gripe from Tom Lane.

8 years agoAdd regression tests for multiple synchronous standbys.
Fujii Masao [Fri, 8 Apr 2016 07:48:53 +0000 (16:48 +0900)]
Add regression tests for multiple synchronous standbys.

Authors: Suraj Kharage, Michael Paquier, Masahiko Sawada, refactored by me
Reviewed-By: Kyotaro Horiguchi
8 years agoUse quicksort, not replacement selection, for external sorting.
Robert Haas [Fri, 8 Apr 2016 06:36:26 +0000 (02:36 -0400)]
Use quicksort, not replacement selection, for external sorting.

We still use replacement selection for the first run of the sort only
and only when the number of tuples is relatively small.  Otherwise,
the first run, and subsequent runs in all cases, are produced using
quicksort.  This tends to be faster except perhaps for very small
amounts of working memory.

Peter Geoghegan, reviewed by Tomas Vondra, Jeff Janes, Mithun Cy,
Greg Stark, and me.

8 years agoExtend relations multiple blocks at a time to improve scalability.
Robert Haas [Fri, 8 Apr 2016 06:04:46 +0000 (02:04 -0400)]
Extend relations multiple blocks at a time to improve scalability.

Contention on the relation extension lock can become quite fierce when
multiple processes are inserting data into the same relation at the same
time at a high rate.  Experimentation shows the extending the relation
multiple blocks at a time improves scalability.

Dilip Kumar, reviewed by Petr Jelinek, Amit Kapila, and me.

8 years agoFix a couple of places in doc that implied there was only one sync standby.
Fujii Masao [Fri, 8 Apr 2016 04:24:50 +0000 (13:24 +0900)]
Fix a couple of places in doc that implied there was only one sync standby.

Thomas Munro

8 years agoUse Foreign Key relationships to infer multi-column join selectivity
Simon Riggs [Fri, 8 Apr 2016 01:51:09 +0000 (02:51 +0100)]
Use Foreign Key relationships to infer multi-column join selectivity

In cases where joins use multiple columns we currently assess each join
separately causing gross mis-estimates for join cardinality.

This patch adds use of FK information for the first time into the
planner. When FKs are present and we have multi-column join information,
plan estimates will be drastically improved. Cases with multiple FKs
are handled, though partial matches are ignored currently.

Net effect is substantial performance improvements for joins in many
common cases. Additional planning time is isolated to cases that are
currently performing poorly, measured at 0.08 - 0.15 ms.

Please watch for planner performance regressions; circumstances seem
unlikely but the law of unintended consequences may apply somewhen.
Additional complex tests welcome to prove this before release.

Tests can be performed using SET enable_fkey_estimates = on | off
using scripts provided during Hackers discussions, message id:
552335D9.3090707@2ndquadrant.com

Authors: Tomas Vondra and David Rowley
Reviewed and tested by Simon Riggs, adding comments only

8 years agoGRANT rights to CURRENT_USER instead of adding roles
Stephen Frost [Thu, 7 Apr 2016 18:40:23 +0000 (14:40 -0400)]
GRANT rights to CURRENT_USER instead of adding roles

We shouldn't be adding roles during the regression tests as that can
cause back-to-back installcheck runs to fail and users running the
regression tests likley don't want those extra roles.

Pointed out by Tom

8 years agoZeroing unused parts ducring tsquery construction.
Teodor Sigaev [Thu, 7 Apr 2016 17:45:24 +0000 (20:45 +0300)]
Zeroing unused parts ducring tsquery construction.

Per investigation failure skink buildfarm member and
RANDOMIZE_ALLOCATED_MEMORY help

8 years agoRefactor join_is_removable() to separate out distinctness-proving logic.
Tom Lane [Thu, 7 Apr 2016 17:11:30 +0000 (13:11 -0400)]
Refactor join_is_removable() to separate out distinctness-proving logic.

Extracted from pending unique-join patch, since this is a rather large
delta but it's simply moving code out into separately-accessible
subroutines.

I (tgl) did choose to add a bit more logic to rel_supports_distinctness,
so that it verifies that there's at least one potentially usable unique
index rather than just checking indexlist != NIL.  Otherwise there's
no functional change here.

David Rowley

8 years agoMake testing of phraseto_tsquery independ from value of
Teodor Sigaev [Thu, 7 Apr 2016 16:28:31 +0000 (19:28 +0300)]
Make testing of phraseto_tsquery independ from value of
default_text_search_config variable.

Per skink buldfarm member

8 years agoDetect SSI conflicts before reporting constraint violations
Kevin Grittner [Thu, 7 Apr 2016 16:12:35 +0000 (11:12 -0500)]
Detect SSI conflicts before reporting constraint violations

While prior to this patch the user-visible effect on the database
of any set of successfully committed serializable transactions was
always consistent with some one-at-a-time order of execution of
those transactions, the presence of declarative constraints could
allow errors to occur which were not possible in any such ordering,
and developers had no good workarounds to prevent user-facing
errors where they were not necessary or desired.  This patch adds
a check for serialization failure ahead of duplicate key checking
so that if a developer explicitly (redundantly) checks for the
pre-existing value they will get the desired serialization failure
where the problem is caused by a concurrent serializable
transaction; otherwise they will get a duplicate key error.

While it would be better if the reads performed by the constraints
could count as part of the work of the transaction for
serialization failure checking, and we will hopefully get there
some day, this patch allows a clean and reliable way for developers
to work around the issue.  In many cases existing code will already
be doing the right thing for this to "just work".

Author: Thomas Munro, with minor editing of docs by me
Reviewed-by: Marko Tiikkaja, Kevin Grittner
8 years agoPhrase full text search.
Teodor Sigaev [Thu, 7 Apr 2016 15:44:18 +0000 (18:44 +0300)]
Phrase full text search.

Patch introduces new text search operator (<-> or <DISTANCE>) into tsquery.
On-disk and binary in/out format of tsquery are backward compatible.
It has two side effect:
- change order for tsquery, so, users, who has a btree index over tsquery,
  should reindex it
- less number of parenthesis in tsquery output, and tsquery becomes more
  readable

Authors: Teodor Sigaev, Oleg Bartunov, Dmitry Ivanov
Reviewers: Alexander Korotkov, Artur Zakirov

8 years agoLoad FK defs into relcache for use by planner
Simon Riggs [Thu, 7 Apr 2016 11:08:33 +0000 (12:08 +0100)]
Load FK defs into relcache for use by planner

Fastpath ignores this if no triggers defined.

Author: Tomas Vondra, with fastpath and comments added by me
Reviewers: David Rowley, Simon Riggs

8 years agoStandardize GetTokenInformation() error reporting.
Noah Misch [Thu, 7 Apr 2016 03:41:43 +0000 (23:41 -0400)]
Standardize GetTokenInformation() error reporting.

Commit c22650cd6450854e1a75064b698d7dcbb4a8821a sparked a discussion
about diverse interpretations of "token user" in error messages.  Expel
old and new specimens of that phrase by making all GetTokenInformation()
callers report errors the way GetTokenUser() has been reporting them.
These error conditions almost can't happen, so users are unlikely to
observe this change.

Reviewed by Tom Lane and Stephen Frost.

8 years agoRemove redundant message in AddUserToTokenDacl().
Noah Misch [Thu, 7 Apr 2016 03:40:51 +0000 (23:40 -0400)]
Remove redundant message in AddUserToTokenDacl().

GetTokenUser() will have reported an adequate error message.  These
error conditions almost can't happen, so users are unlikely to observe
this change.

Reviewed by Tom Lane and Stephen Frost.

8 years agoBump catversion for pg_dump dump catalog ACL patches
Stephen Frost [Thu, 7 Apr 2016 03:04:48 +0000 (23:04 -0400)]
Bump catversion for pg_dump dump catalog ACL patches

Pointed out by Tom.

8 years agoUse GRANT system to manage access to sensitive functions
Stephen Frost [Thu, 7 Apr 2016 01:45:32 +0000 (21:45 -0400)]
Use GRANT system to manage access to sensitive functions

Now that pg_dump will properly dump out any ACL changes made to
functions which exist in pg_catalog, switch to using the GRANT system
to manage access to those functions.

This means removing 'if (!superuser()) ereport()' checks from the
functions themselves and then REVOKEing EXECUTE right from 'public' for
these functions in system_views.sql.

Reviews by Alexander Korotkov, Jose Luis Tallon

8 years agoIn pg_dump, include pg_catalog and extension ACLs, if changed
Stephen Frost [Thu, 7 Apr 2016 01:45:32 +0000 (21:45 -0400)]
In pg_dump, include pg_catalog and extension ACLs, if changed

Now that all of the infrastructure exists, add in the ability to
dump out the ACLs of the objects inside of pg_catalog or the ACLs
for objects which are members of extensions, but only if they have
been changed from their original values.

The original values are tracked in pg_init_privs.  When pg_dump'ing
9.6-and-above databases, we will dump out the ACLs for all objects
in pg_catalog and the ACLs for all extension members, where the ACL
has been changed from the original value which was set during either
initdb or CREATE EXTENSION.

This should not change dumps against pre-9.6 databases.

Reviews by Alexander Korotkov, Jose Luis Tallon

8 years agoIn pg_dump, split "dump" into "dump" and "dump_contains"
Stephen Frost [Thu, 7 Apr 2016 01:45:32 +0000 (21:45 -0400)]
In pg_dump, split "dump" into "dump" and "dump_contains"

Historically, the "dump" component of the namespace has been used
to decide if the objects inside of the namespace should be dumped
also.  Given that "dump" is now a bitmask and may be partial, and
we may want to dump out all components of the namespace object but
only some of the components of objects contained in the namespace,
create a "dump_contains" bitmask which will represent what components
of the objects inside of a namespace should be dumped out.

No behavior change here, but in preparation for a change where we
will dump out just the ACLs of objects in pg_catalog, but we might
not dump out the ACL of the pg_catalog namespace itself (for instance,
when it hasn't been changed from the value set at initdb time).

Reviews by Alexander Korotkov, Jose Luis Tallon

8 years agoIn pg_dump, use a bitmap to represent what to include
Stephen Frost [Thu, 7 Apr 2016 01:45:32 +0000 (21:45 -0400)]
In pg_dump, use a bitmap to represent what to include

pg_dump has historically used a simple boolean 'dump' value to indicate
if a given object should be included in the dump or not.  Instead, use
a bitmap which breaks down the components of an object into their
distinct pieces and use that bitmap to only include the components
requested.

This does not include any behavioral change, but is in preperation for
the change to dump out just ACLs for objects in pg_catalog.

Reviews by Alexander Korotkov, Jose Luis Tallon

8 years agoAdd new catalog called pg_init_privs
Stephen Frost [Thu, 7 Apr 2016 01:45:32 +0000 (21:45 -0400)]
Add new catalog called pg_init_privs

This new catalog holds the privileges which the system was
initialized with at initdb time, along with any permissions set
by extensions at CREATE EXTENSION time.  This allows pg_dump
(and any other similar use-cases) to detect when the privileges
set on initdb-created or extension-created objects have been
changed from what they were set to at initdb/extension-creation
time and handle those changes appropriately.

Reviews by Alexander Korotkov, Jose Luis Tallon

8 years agoAdd jsonb_insert
Teodor Sigaev [Wed, 6 Apr 2016 16:20:17 +0000 (19:20 +0300)]
Add jsonb_insert

It inserts a new value into an jsonb array at arbitrary position or
a new key to jsonb object.

Author: Dmitry Dolgov
Reviewers: Petr Jelinek, Vitaly Burovoy, Andrew Dunstan

8 years agopg_dump: Add table qualifications to some tags
Peter Eisentraut [Thu, 25 Feb 2016 23:56:37 +0000 (18:56 -0500)]
pg_dump: Add table qualifications to some tags

Some object types have names that are only unique for one table.  But
for those we generally didn't put the table name into the dump TOC tag.
So it was impossible to identify these objects if the same name was used
for multiple tables.  This affects policies, column defaults,
constraints, triggers, and rules.

Fix by adding the table name to the TOC tag, so that it now reads
"$schema $table $object".

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
8 years agoRun pgindent on a batch of (mostly-planner-related) source files.
Tom Lane [Wed, 6 Apr 2016 15:34:02 +0000 (11:34 -0400)]
Run pgindent on a batch of (mostly-planner-related) source files.

Getting annoyed at the amount of unrelated chatter I get from pgindent'ing
Rowley's unique-joins patch.  Re-indent all the files it touches.

8 years agoModify test_decoding/messages to remove non-ascii chars
Simon Riggs [Wed, 6 Apr 2016 13:55:11 +0000 (14:55 +0100)]
Modify test_decoding/messages to remove non-ascii chars

8 years agoUse proper format specifier %X/%X for LSN, again.
Fujii Masao [Wed, 6 Apr 2016 13:20:52 +0000 (22:20 +0900)]
Use proper format specifier %X/%X for LSN, again.

Commit cee31f5 fixed this problem, but commit 989be08 accidentally
reverted the fix.

Thomas Munro

8 years agoRevert bf08f2292ffca14fd133aa0901d1563b6ecd6894
Simon Riggs [Wed, 6 Apr 2016 13:03:46 +0000 (14:03 +0100)]
Revert bf08f2292ffca14fd133aa0901d1563b6ecd6894

Remove recent changes to logging XLOG_RUNNING_XACTS by request.

8 years agoGeneric Messages for Logical Decoding
Simon Riggs [Wed, 6 Apr 2016 09:05:41 +0000 (10:05 +0100)]
Generic Messages for Logical Decoding

API and mechanism to allow generic messages to be inserted into WAL that are
intended to be read by logical decoding plugins. This commit adds an optional
new callback to the logical decoding API.

Messages are either text or bytea. Messages can be transactional, or not, and
are identified by a prefix to allow multiple concurrent decoding plugins.

(Not to be confused with Generic WAL records, which are intended to allow crash
recovery of extensible objects.)

Author: Petr Jelinek and Andres Freund
Reviewers: Artur Zakirov, Tomas Vondra, Simon Riggs
Discussion: 5685F999.6010202@2ndquadrant.com

8 years agoSupport multiple synchronous standby servers.
Fujii Masao [Wed, 6 Apr 2016 08:18:25 +0000 (17:18 +0900)]
Support multiple synchronous standby servers.

Previously synchronous replication offered only the ability to confirm
that all changes made by a transaction had been transferred to at most
one synchronous standby server.

This commit extends synchronous replication so that it supports multiple
synchronous standby servers. It enables users to consider one or more
standby servers as synchronous, and increase the level of transaction
durability by ensuring that transaction commits wait for replies from
all of those synchronous standbys.

Multiple synchronous standby servers are configured in
synchronous_standby_names which is extended to support new syntax of
'num_sync ( standby_name [ , ... ] )', where num_sync specifies
the number of synchronous standbys that transaction commits need to
wait for replies from and standby_name is the name of a standby
server.

The syntax of 'standby_name [ , ... ]' which was used in 9.5 or before
is also still supported. It's the same as new syntax with num_sync=1.

This commit doesn't include "quorum commit" feature which was discussed
in pgsql-hackers. Synchronous standbys are chosen based on their priorities.
synchronous_standby_names determines the priority of each standby for
being chosen as a synchronous standby. The standbys whose names appear
earlier in the list are given higher priority and will be considered as
synchronous. Other standby servers appearing later in this list
represent potential synchronous standbys.

The regression test for multiple synchronous standbys is not included
in this commit. It should come later.

Authors: Sawada Masahiko, Beena Emerson, Michael Paquier, Fujii Masao
Reviewed-By: Kyotaro Horiguchi, Amit Kapila, Robert Haas, Simon Riggs,
Amit Langote, Thomas Munro, Sameer Thakur, Suraj Kharage, Abhijit Menon-Sen,
Rajeev Rastogi

Many thanks to the various individuals who were involved in
discussing and developing this feature.

8 years agoFix broken ALTER INDEX documentation
Alvaro Herrera [Tue, 5 Apr 2016 22:03:42 +0000 (19:03 -0300)]
Fix broken ALTER INDEX documentation

Commit b8a91d9d1c put the description of the new IF EXISTS clause in the
wrong place -- move it where it belongs.

Backpatch to 9.2.

8 years agoSupport ALTER THING .. DEPENDS ON EXTENSION
Alvaro Herrera [Tue, 5 Apr 2016 21:38:54 +0000 (18:38 -0300)]
Support ALTER THING .. DEPENDS ON EXTENSION

This introduces a new dependency type which marks an object as depending
on an extension, such that if the extension is dropped, the object
automatically goes away; and also, if the database is dumped, the object
is included in the dump output.  Currently the grammar supports this for
indexes, triggers, materialized views and functions only, although the
utility code is generic so adding support for more object types is a
matter of touching the parser rules only.

Author: Abhijit Menon-Sen
Reviewed-by: Alexander Korotkov, Álvaro Herrera
Discussion: http://www.postgresql.org/message-id/20160115062649.GA5068@toroid.org

8 years agoFix parallel-safety code for parallel aggregation.
Robert Haas [Tue, 5 Apr 2016 20:06:15 +0000 (16:06 -0400)]
Fix parallel-safety code for parallel aggregation.

has_parallel_hazard() was ignoring the proparallel markings for
aggregates, which is no good.  Fix that.  There was no way to mark
an aggregate as actually being parallel-safe, either, so add a
PARALLEL option to CREATE AGGREGATE.

Patch by me, reviewed by David Rowley.

8 years agoAlign all shared memory allocations to cache line boundaries.
Robert Haas [Tue, 5 Apr 2016 19:47:49 +0000 (15:47 -0400)]
Align all shared memory allocations to cache line boundaries.

Experimentation shows this only costs about 6kB, which seems well
worth it given the major performance effects that can be caused
by insufficient alignment, especially on larger systems.

Discussion: 14166.1458924422@sss.pgh.pa.us

8 years agoFix PL/Python for recursion and interleaved set-returning functions.
Tom Lane [Tue, 5 Apr 2016 18:50:30 +0000 (14:50 -0400)]
Fix PL/Python for recursion and interleaved set-returning functions.

PL/Python failed if a PL/Python function was invoked recursively via SPI,
since arguments are passed to the function in its global dictionary
(a horrible decision that's far too ancient to undo) and it would delete
those dictionary entries on function exit, leaving the outer recursion
level(s) without any arguments.  Not deleting them would be little better,
since the outer levels would then see the innermost level's arguments.

Since PL/Python uses ValuePerCall mode for evaluating set-returning
functions, it's possible for multiple executions of the same SRF to be
interleaved within a query.  PL/Python failed in such a case, because
it stored only one iterator per function, directly in the function's
PLyProcedure struct.  Moreover, one interleaved instance of the SRF
would see argument values that should belong to another.

Hence, invent code for saving and restoring the argument entries.  To fix
the recursion case, we only need to save at recursive entry and restore
at recursive exit, so the overhead in non-recursive cases is negligible.
To fix the SRF case, we have to save when suspending a SRF and restore
when resuming it, which is potentially not negligible; but fortunately
this is mostly a matter of manipulating Python object refcounts and
should not involve much physical data copying.

Also, store the Python iterator and saved argument values in a structure
associated with the SRF call site rather than the function itself.  This
requires adding a memory context deletion callback to ensure that the SRF
state is cleaned up if the calling query exits before running the SRF to
completion.  Without that we'd leak a refcount to the iterator object in
such a case, resulting in session-lifespan memory leakage.  (In the
pre-existing code, there was no memory leak because there was only one
iterator pointer, but what would happen is that the previous iterator
would be resumed by the next query attempting to use the SRF.  Hardly the
semantics we want.)

We can buy back some of whatever overhead we've added by getting rid of
PLy_function_delete_args(), which seems a useless activity: there is no
need to delete argument entries from the global dictionary on exit,
since the next time anyone would see the global dict is on the next
fresh call of the PL/Python function, at which time we'd overwrite those
entries with new arg values anyway.

Also clean up some really ugly coding in the SRF implementation, including
such gems as returning directly out of a PG_TRY block.  (The only reason
that failed to crash hard was that all existing call sites immediately
exited their own PG_TRY blocks, popping the dangling longjmp pointer before
there was any chance of it being used.)

In principle this is a bug fix; but it seems a bit too invasive relative to
its value for a back-patch, and besides the fix depends on memory context
callbacks so it could not go back further than 9.5 anyway.

Alexey Grishchenko and Tom Lane

8 years agoAdd parallel query support functions for assorted aggregates.
Robert Haas [Tue, 5 Apr 2016 18:24:59 +0000 (14:24 -0400)]
Add parallel query support functions for assorted aggregates.

This lets us use parallel aggregate for a variety of useful cases
that didn't work before, like sum(int8), sum(numeric), several
versions of avg(), and various other functions.

Add some regression tests, as well, testing the general sanity of
these and future catalog entries.

David Rowley, reviewed by Tomas Vondra, with a few further changes
by me.

8 years agoImplement backup API functions for non-exclusive backups
Magnus Hagander [Tue, 5 Apr 2016 18:03:49 +0000 (20:03 +0200)]
Implement backup API functions for non-exclusive backups

Previously non-exclusive backups had to be done using the replication protocol
and pg_basebackup. With this commit it's now possible to make them using
pg_start_backup/pg_stop_backup as well, as long as the backup program can
maintain a persistent connection to the database.

Doing this, backup_label and tablespace_map are returned as results from
pg_stop_backup() instead of being written to the data directory. This makes
the server safe from a crash during an ongoing backup, which can be a problem
with exclusive backups.

The old syntax of the functions remain and work exactly as before, but since the
new syntax is safer this should eventually be deprecated and removed.

Only reference documentation is included. The main section on backup still needs
to be rewritten to cover this, but since that is already scheduled for a separate
large rewrite, it's not included in this patch.

Reviewed by David Steele and Amit Kapila

8 years agoFix typo
Magnus Hagander [Tue, 5 Apr 2016 09:05:01 +0000 (11:05 +0200)]
Fix typo

Etsuro Fujita

8 years agoFix error message from wal_level value renaming
Peter Eisentraut [Tue, 5 Apr 2016 01:17:54 +0000 (21:17 -0400)]
Fix error message from wal_level value renaming

found by Ian Barwick

8 years agoDisallow newlines in parameter values to be set in ALTER SYSTEM.
Tom Lane [Mon, 4 Apr 2016 22:05:23 +0000 (18:05 -0400)]
Disallow newlines in parameter values to be set in ALTER SYSTEM.

As noted by Julian Schauder in bug #14063, the configuration-file parser
doesn't support embedded newlines in string literals.  While there might
someday be a good reason to remove that restriction, there doesn't seem
to be one right now.  However, ALTER SYSTEM SET could accept strings
containing newlines, since many of the variable-specific value-checking
routines would just see a newline as whitespace.  This led to writing a
postgresql.auto.conf file that was broken and had to be removed manually.

Pending a reason to work harder, just throw an error if someone tries this.

In passing, fix several places in the ALTER SYSTEM logic that failed to
provide an errcode() for an ereport(), and thus would falsely log the
failure as an internal XX000 error.

Back-patch to 9.4 where ALTER SYSTEM was introduced.

8 years agoDisplay WAL pointer in rm_redo error callback
Alvaro Herrera [Mon, 4 Apr 2016 21:12:12 +0000 (18:12 -0300)]
Display WAL pointer in rm_redo error callback

This makes it easier to identify the source of a recovery problem
in case of a bug or data corruption.

8 years agoAdd a few comments about ANALYZE's strategy for collecting MCVs.
Tom Lane [Mon, 4 Apr 2016 21:06:33 +0000 (17:06 -0400)]
Add a few comments about ANALYZE's strategy for collecting MCVs.

Alex Shulgin complained that the underlying strategy wasn't all that
apparent, particularly not the fact that we intentionally have two
code paths depending on whether we think the column has a limited set
of possible values or not.  Try to make it clearer.

8 years agoPartially revert commit 3d3bf62f30200500637b24fdb7b992a99f9704c3.
Tom Lane [Mon, 4 Apr 2016 20:48:13 +0000 (16:48 -0400)]
Partially revert commit 3d3bf62f30200500637b24fdb7b992a99f9704c3.

On reflection, the pre-existing logic in ANALYZE is specifically meant to
compare the frequency of a candidate MCV against the estimated frequency of
a random distinct value across the whole table.  The change to compare it
against the average frequency of values actually seen in the sample doesn't
seem very principled, and if anything it would make us less likely not more
likely to consider a value an MCV.  So revert that, but keep the aspect of
considering only nonnull values, which definitely is correct.

In passing, rename the local variables in these stanzas to
"ndistinct_table", to avoid confusion with the "ndistinct" that appears at
an outer scope in compute_scalar_stats.

8 years agoSilence compiler warning
Alvaro Herrera [Mon, 4 Apr 2016 20:07:18 +0000 (17:07 -0300)]
Silence compiler warning

Reported by Peter Eisentraut to occur on 32bit systems

8 years agoAdd a \gexec command to psql for evaluation of computed queries.
Tom Lane [Mon, 4 Apr 2016 19:25:16 +0000 (15:25 -0400)]
Add a \gexec command to psql for evaluation of computed queries.

\gexec executes the just-entered query, like \g, but instead of printing
the results it takes each field as a SQL command to send to the server.
Computing a series of queries to be executed is a fairly common thing,
but up to now you always had to resort to kluges like writing the queries
to a file and then inputting the file.  Now it can be done with no
intermediate step.

The implementation is fairly straightforward except for its interaction
with FETCH_COUNT.  ExecQueryUsingCursor isn't capable of being called
recursively, and even if it were, its need to create a transaction
block interferes unpleasantly with the desired behavior of \gexec after
a failure of a generated query (i.e., that it can continue).  Therefore,
disable use of ExecQueryUsingCursor when doing the master \gexec query.
We can still apply it to individual generated queries, however, and there
might be some value in doing so.

While testing this feature's interaction with single-step mode, I (tgl) was
led to conclude that SendQuery needs to recognize SIGINT (cancel_pressed)
as a negative response to the single-step prompt.  Perhaps that's a
back-patchable bug fix, but for now I just included it here.

Corey Huinker, reviewed by Jim Nasby, Daniel Vérité, and myself

8 years agoIntroduce a LOG_SERVER_ONLY ereport level, which is never sent to client.
Tom Lane [Mon, 4 Apr 2016 16:32:42 +0000 (12:32 -0400)]
Introduce a LOG_SERVER_ONLY ereport level, which is never sent to client.

This elevel is useful for logging audit messages and similar information
that should not be passed to the client.  It's equivalent to LOG in terms
of decisions about logging priority in the postmaster log, but messages
with this elevel will never be sent to the client.

In the current implementation, it's just an alias for the longstanding
COMMERROR elevel (or more accurately, we've made COMMERROR an alias for
this).  At some point it might be interesting to allow a LOG_ONLY flag to
be attached to any elevel, but that would be considerably more complicated,
and it's not clear there's enough use-cases to justify the extra work.
For now, let's just take the easy 90% solution.

David Steele, reviewed by Fabien Coelho, Petr Jelínek, and myself

8 years agoFix latent portability issue in pgwin32_dispatch_queued_signals().
Tom Lane [Mon, 4 Apr 2016 15:13:17 +0000 (11:13 -0400)]
Fix latent portability issue in pgwin32_dispatch_queued_signals().

The first iteration of the signal-checking loop would compute sigmask(0)
which expands to 1<<(-1) which is undefined behavior according to the
C standard.  The lack of field reports of trouble suggest that it
evaluates to 0 on all existing Windows compilers, but that's hardly
something to rely on.  Since signal 0 isn't a queueable signal anyway,
we can just make the loop iterate from 1 instead, and save a few cycles
as well as avoiding the undefined behavior.

In passing, avoid evaluating the volatile expression UNBLOCKED_SIGNAL_QUEUE
twice in a row; there's no reason to waste cycles like that.

Noted by Aleksander Alekseev, though this isn't his proposed fix.
Back-patch to all supported branches.

8 years agoFix typo
Teodor Sigaev [Mon, 4 Apr 2016 11:55:29 +0000 (14:55 +0300)]
Fix typo

Michael Paquier

8 years agofix typo
Teodor Sigaev [Mon, 4 Apr 2016 10:15:24 +0000 (13:15 +0300)]
fix typo

Andreas Ulbrich

8 years agoImprove estimate of distinct values in estimate_num_groups().
Dean Rasheed [Mon, 4 Apr 2016 11:41:56 +0000 (12:41 +0100)]
Improve estimate of distinct values in estimate_num_groups().

When adjusting the estimate for the number of distinct values from a
rel in a grouped query to take into account the selectivity of the
rel's restrictions, use a formula that is less likely to produce
under-estimates.

The old formula simply multiplied the number of distinct values in the
rel by the restriction selectivity, which would be correct if the
restrictions were fully correlated with the grouping expressions, but
can produce significant under-estimates in cases where they are not
well correlated.

The new formula is based on the random selection probability, and so
assumes that the restrictions are not correlated with the grouping
expressions. This is guaranteed to produce larger estimates, and of
course risks over-estimating in cases where the restrictions are
correlated, but that has less severe consequences than
under-estimating, which might lead to a HashAgg that consumes an
excessive amount of memory.

This could possibly be improved upon in the future by identifying
correlated restrictions and using a hybrid of the old and new
formulae.

Author: Tomas Vondra, with some hacking be me
Reviewed-by: Mark Dilger, Alexander Korotkov, Dean Rasheed and Tom Lane
Discussion: http://www.postgresql.org/message-id/flat/56CD0381.5060502@2ndquadrant.com

8 years agoAvoid archiving XLOG_RUNNING_XACTS on idle server
Simon Riggs [Mon, 4 Apr 2016 06:18:05 +0000 (07:18 +0100)]
Avoid archiving XLOG_RUNNING_XACTS on idle server

If archive_timeout > 0 we should avoid logging XLOG_RUNNING_XACTS if idle.

Bug 13685 reported by Laurence Rowe, investigated in detail by Michael Paquier,
though this is not his proposed fix.
20151016203031.3019.72930@wrigleys.postgresql.org

Simple non-invasive patch to allow later backpatch to 9.4 and 9.5

8 years agoClean up dubious code in contrib/seg.
Tom Lane [Sun, 3 Apr 2016 21:36:53 +0000 (17:36 -0400)]
Clean up dubious code in contrib/seg.

The restore() function assumed that the result of sprintf() with %e format
would necessarily contain an 'e', which is false: what if the supplied
number is an infinity or NaN?  If that did happen, we'd get a
null-pointer-dereference core dump.  The case appears impossible currently,
because seg_in() does not accept such values, and there are no seg-creating
functions that would create one.  But it seems unwise to rely on it never
happening in future.

Quite aside from that, the code was pretty ugly: it relied on modifying a
static format string when it could use a "*" precision argument, and it
used strtok() entirely gratuitously, and it stripped off trailing spaces
by hand instead of just not asking for them to begin with.

Coverity noticed the potential null pointer dereference (though I wonder
why it didn't complain years ago, since this code is ancient).

Since this is just code cleanup and forestalling a hypothetical future
bug, there seems no need for back-patching.

8 years agoFix contrib/bloom to not fail under CLOBBER_CACHE_ALWAYS.
Tom Lane [Sun, 3 Apr 2016 19:16:07 +0000 (15:16 -0400)]
Fix contrib/bloom to not fail under CLOBBER_CACHE_ALWAYS.

The code was supposing that rd_amcache wouldn't disappear from under it
during a scan; which is wrong.  Copy the data out of the relcache rather
than trying to reference it there.

8 years agoClean up some stuff in new contrib/bloom module.
Tom Lane [Sun, 3 Apr 2016 18:17:20 +0000 (14:17 -0400)]
Clean up some stuff in new contrib/bloom module.

Coverity complained about implicit sign-extension in the
BloomPageGetFreeSpace macro, probably because sizeOfBloomTuple isn't wide
enough for size calculations.  No overflow is really possible as long as
maxoff and sizeOfBloomTuple are small enough to represent a realistic
situation, but it seems like a good idea to declare sizeOfBloomTuple as
Size not int32.

Add missing check on BloomPageAddItem() result, again from Coverity.

Avoid core dump due to not allocating so->sign array when
scan->numberOfKeys is zero.  Also thanks to Coverity.

Use FLEXIBLE_ARRAY_MEMBER rather than declaring an array as size 1
when it isn't necessarily.

Very minor beautification of related code.

Unfortunately, none of the Coverity-detected mistakes look like they
could account for the remaining buildfarm unhappiness with this
module.  It's barely possible that the FLEXIBLE_ARRAY_MEMBER mistake
does account for that, if it's enabling bogus compiler optimizations;
but I'm not terribly optimistic.  We probably still have bugs to
find here.

8 years agoAvoid pin scan for replay of XLOG_BTREE_VACUUM in all cases
Simon Riggs [Sun, 3 Apr 2016 16:46:09 +0000 (17:46 +0100)]
Avoid pin scan for replay of XLOG_BTREE_VACUUM in all cases

Replay of XLOG_BTREE_VACUUM during Hot Standby was previously thought to require
complex interlocking that matched the requirements on the master. This required
an O(N) operation that became a significant problem with large indexes, causing
replication delays of seconds or in some cases minutes while the
XLOG_BTREE_VACUUM was replayed.

This commit skips the pin scan that was previously required, by observing in
detail when and how it is safe to do so, with full documentation. The pin
scan is skipped only in replay; the VACUUM code path on master is not
touched here and WAL is identical.

The current commit applies in all cases, effectively replacing commit
687f2cd7a0150647794efe432ae0397cb41b60ff.

8 years agoAdd psql \errverbose command to see last server error at full verbosity.
Tom Lane [Sun, 3 Apr 2016 16:29:55 +0000 (12:29 -0400)]
Add psql \errverbose command to see last server error at full verbosity.

Often, upon getting an unexpected error in psql, one's first wish is that
the verbosity setting had been higher; for example, to be able to see the
schema-name field or the server code location info.  Up to now the only way
has been to adjust the VERBOSITY variable and repeat the failing query.
That's a pain, and it doesn't work if the error isn't reproducible.

This commit adds a psql feature that redisplays the most recent server
error at full verbosity, without needing to make any variable changes or
re-execute the failed command.  We just need to hang onto the latest error
PGresult in case the user executes \errverbose, and then apply libpq's
new PQresultVerboseErrorMessage() function to it.  This will consume
some trivial amount of psql memory, but otherwise the cost when the
feature isn't used should be negligible.

Alex Shulgin, reviewed by Daniel Vérité, some improvements by me

8 years agoAdd libpq support for recreating an error message with different verbosity.
Tom Lane [Sun, 3 Apr 2016 16:24:54 +0000 (12:24 -0400)]
Add libpq support for recreating an error message with different verbosity.

Often, upon getting an unexpected error in psql, one's first wish is that
the verbosity setting had been higher; for example, to be able to see the
schema-name field or the server code location info.  Up to now the only way
has been to adjust the VERBOSITY variable and repeat the failing query.
That's a pain, and it doesn't work if the error isn't reproducible.

This commit adds support in libpq for regenerating the error message for
an existing error PGresult at any desired verbosity level.  This is almost
just a matter of refactoring the existing code into a subroutine, but there
is one bit of possibly-needed information that was not getting put into
PGresults: the text of the last query sent to the server.  We must add that
string to the contents of an error PGresult.  But we only need to save it
if it might be used, which with the existing error-formatting code only
happens if there is a PG_DIAG_STATEMENT_POSITION error field, which is
probably pretty rare for errors in production situations.  So really the
overhead when the feature isn't used should be negligible.

Alex Shulgin, reviewed by Daniel Vérité, some improvements by me

8 years agoAdd missing "static".
Tom Lane [Sat, 2 Apr 2016 17:59:11 +0000 (13:59 -0400)]
Add missing "static".

Per buildfarm member pademelon.

8 years agoMake all the declarations of WaitEventSetWaitBlock be marked "inline".
Tom Lane [Sat, 2 Apr 2016 17:55:44 +0000 (13:55 -0400)]
Make all the declarations of WaitEventSetWaitBlock be marked "inline".

The inconsistency here triggered compiler warnings on some buildfarm
members, and it's surely pretty pointless.

8 years agoSuppress compiler warning.
Tom Lane [Sat, 2 Apr 2016 17:49:17 +0000 (13:49 -0400)]
Suppress compiler warning.

Some buildfarm members are showing "comparison is always false due to
limited range of data type" complaints on this test, so #ifdef it out
on machines with 32-bit int.

8 years agoFix condition in e9e441c9fac6cbc0510cded6abb9d0e6b646ecaf
Teodor Sigaev [Sat, 2 Apr 2016 15:36:46 +0000 (18:36 +0300)]
Fix condition in e9e441c9fac6cbc0510cded6abb9d0e6b646ecaf

Comment is right, but if - not.

8 years agoFix typo in pg_regress.c
Stephen Frost [Sat, 2 Apr 2016 15:12:17 +0000 (11:12 -0400)]
Fix typo in pg_regress.c

s/afer/after

Pointed out by Andreas 'ads' Scherbaum

8 years agoPrevent mark as deleted and as 'has free space' page in bloom module
Teodor Sigaev [Sat, 2 Apr 2016 11:20:46 +0000 (14:20 +0300)]
Prevent mark as deleted and as 'has free space' page in bloom module

Vacuum might put page into list of pages with some free space and mark as
deleted at the same time.

8 years agoFixes in bloom contrib module
Teodor Sigaev [Sat, 2 Apr 2016 10:47:04 +0000 (13:47 +0300)]
Fixes in bloom contrib module

Looking at result of buildfarm member jaguarundi it seems to me that
BloomOptions isn't inited sometime, but I don't see yet how it's possible.
Nevertheless, check of signature length's is missed, so, add
a limit of it. Also add missed GenericXLogAbort() in case of already
deleted page in vacuum + minor code refactoring.

8 years agoRefer to a TOKEN_USER payload as a "token user," not as a "user token".
Noah Misch [Sat, 2 Apr 2016 01:53:18 +0000 (21:53 -0400)]
Refer to a TOKEN_USER payload as a "token user," not as a "user token".

This corrects messages for can't-happen errors.  The corresponding "user
token" appears in the HANDLE argument of GetTokenInformation().

8 years agoCopyedit comments and documentation.
Noah Misch [Sat, 2 Apr 2016 01:53:10 +0000 (21:53 -0400)]
Copyedit comments and documentation.

8 years agotest_slot_timelines: Fix alternate expected output
Alvaro Herrera [Fri, 1 Apr 2016 21:36:07 +0000 (18:36 -0300)]
test_slot_timelines: Fix alternate expected output

8 years agoOmit null rows when setting the threshold for what's a most-common value.
Tom Lane [Fri, 1 Apr 2016 21:03:18 +0000 (17:03 -0400)]
Omit null rows when setting the threshold for what's a most-common value.

As with the previous patch, large numbers of null rows could skew this
calculation unfavorably, causing us to discard values that have a
legitimate claim to be MCVs, since our definition of MCV is that it's
most common among the non-null population of the column.  Hence, make
the numerator of avgcount be the number of non-null sample values not
the number of sample rows; likewise for maxmincount in the
compute_scalar_stats variant.

Also, make the denominator be the number of distinct values actually
observed in the sample, rather than reversing it back out of the computed
stadistinct.  This avoids depending on the accuracy of the Haas-Stokes
approximation, and really it's what we want anyway; the threshold should
depend only on what we see in the sample, not on what we extrapolate
about the contents of the whole column.

Alex Shulgin, reviewed by Tomas Vondra and myself

8 years agopgbench: Remove unused parameter
Alvaro Herrera [Fri, 1 Apr 2016 20:10:30 +0000 (17:10 -0300)]
pgbench: Remove unused parameter

For some reason this parameter was introduced as unused in 3da0dfb4b146,
and has never been used for anything.  Remove it.

Author: Fabien Coelho

8 years agoOmit null rows when applying the Haas-Stokes estimator for ndistinct.
Tom Lane [Fri, 1 Apr 2016 19:47:52 +0000 (15:47 -0400)]
Omit null rows when applying the Haas-Stokes estimator for ndistinct.

Previously, we included null rows in the values of n and N that went
into the formula, which amounts to considering null as a value in its
own right; but the d and f1 values do not include nulls.  This is
inconsistent, and it contributes to significant underestimation of
ndistinct when the column is mostly nulls.  In any case stadistinct
is defined as the number of distinct non-null values, so we should
exclude nulls when doing this computation.

This is an aboriginal bug in our application of the Haas-Stokes formula,
but we'll refrain from back-patching for fear of destabilizing plan
choices in released branches.

While at it, make the code a bit more readable by omitting unnecessary
casts and intermediate variables.

Observation and original patch by Tomas Vondra, adjusted to fix both
uses of the formula by Alex Shulgin, cosmetic improvements by me

8 years agoFix logical_decoding_timelines test crashes
Alvaro Herrera [Fri, 1 Apr 2016 19:47:00 +0000 (16:47 -0300)]
Fix logical_decoding_timelines test crashes

In the test_slot_timelines test module, we were abusing passing NULL
values which was received as zeroes in x86, but this breaks in ARM
(buildfarm member hamster) by crashing instead.  Fix the breakage by
marking these functions as STRICT; the InvalidXid value that was
previously implicit in NULL values (on x86 at least) can now be passed
as 0.  Failing to follow the fmgr protocol to check for NULLs beforehand
was causing ARM to fail, as evidenced by segmentation faults in
buildfarm member hamster.

In order to use the new functionality in the test script, use COALESCE
in the right spot to avoid forwarding NULL values.

This was diagnosed from the hamster crash by Craig Ringer, who also
proposed a different patch (checking for NULL values explicitely in the
C function code, and keeping the non-strictness in the C functions).
I decided to go with this approach instead.

8 years agoFixes in bloom contrib module missed during review
Teodor Sigaev [Fri, 1 Apr 2016 17:09:13 +0000 (20:09 +0300)]
Fixes in bloom contrib module missed during review

- macroses llike (var & FLAG) are changed to ((var & FLAG) != 0)
- do not copy uninitialized part of notFullPage array to page

8 years agoType names should not be quoted
Alvaro Herrera [Fri, 1 Apr 2016 16:35:48 +0000 (13:35 -0300)]
Type names should not be quoted

Our actual convention, contrary to what I said in 59a2111b23f, is not to
quote type names, as evidenced by unquoted use of format_type_be()
result value in error messages.  Remove quotes from recently tweaked
messages accordingly.

Per note from Tom Lane

8 years agoGet rid of minus zero in box regression test.
Tom Lane [Fri, 1 Apr 2016 16:25:17 +0000 (12:25 -0400)]
Get rid of minus zero in box regression test.

Commit acdf2a8b added a test case involving minus zero as a box endpoint.
This is not very portable, as evidenced by the several older buildfarm
members that are failing on the test because they print minus zero as
just "0".  If there were any significant reason to test this behavior,
we could consider carrying a separate expected-file; but it doesn't look
to me like there's adequate justification to accept such a maintenance
burden.  Just change the test to use plain zero, instead.

8 years agoFix oversight in getParamDescriptions(), and improve comments.
Tom Lane [Fri, 1 Apr 2016 16:14:08 +0000 (12:14 -0400)]
Fix oversight in getParamDescriptions(), and improve comments.

When getParamDescriptions was changed to handle out-of-memory better
by cribbing error recovery logic from getRowDescriptions/getAnotherTuple,
somebody omitted to copy the stanza about checking for excess data in
the message.  But you need to do that, since continue'ing out of the
switch in pqParseInput3 means no such check gets applied there anymore.
Noted while looking at Michael Paquier's patch that made yet another
copy of this advance_and_error logic.

(This whole business desperately needs refactoring, because I sure don't
want to see a dozen copies of this code, but that's where we seem to be
headed.  What's more, the "suspend parsing on EOF return" convention is a
holdover from protocol 2 and shouldn't exist at all in protocol 3, because
we don't process partial messages anymore.  But for now, just fix the
obvious bug.)

Also, fix some wrong/missing comments about what the API spec is
for these three functions.

This doesn't seem worthy of back-patching, even though it's a bug;
the case shouldn't ever arise in the field.

8 years agoFix English in bloom module documentation
Teodor Sigaev [Fri, 1 Apr 2016 15:47:44 +0000 (18:47 +0300)]
Fix English in bloom module documentation

Author: Erik Rijkers

8 years agoBloom index contrib module
Teodor Sigaev [Fri, 1 Apr 2016 13:42:24 +0000 (16:42 +0300)]
Bloom index contrib module

Module provides new access method. It is actually a simple Bloom filter
implemented as pgsql's index. It could give some benefits on search
with large number of columns.

Module is a single way to test generic WAL interface committed earlier.

Author: Teodor Sigaev, Alexander Korotkov
Reviewers: Aleksander Alekseev, Michael Paquier, Jim Nasby

8 years agoFix typo in generic wal docs
Teodor Sigaev [Fri, 1 Apr 2016 13:37:42 +0000 (16:37 +0300)]
Fix typo in generic wal docs

Markus Nullmeier

8 years agoAdd Generic WAL interface
Teodor Sigaev [Fri, 1 Apr 2016 09:21:48 +0000 (12:21 +0300)]
Add Generic WAL interface

This interface is designed to give an access to WAL for extensions which
could implement new access method, for example. Previously it was
impossible because restoring from custom WAL would need to access system
catalog to find a redo custom function. This patch suggests generic way
to describe changes on page with standart layout.

Bump XLOG_PAGE_MAGIC because of new record type.

Author: Alexander Korotkov with a help of Petr Jelinek, Markus Nullmeier and
minor editorization by my
Reviewers: Petr Jelinek, Alvaro Herrera, Teodor Sigaev, Jim Nasby,
Michael Paquier

8 years agoAnother zic portability fix.
Tom Lane [Thu, 31 Mar 2016 20:14:55 +0000 (16:14 -0400)]
Another zic portability fix.

I should have remembered that we can't use INT64_MODIFIER with sscanf():
configure chooses that to work with snprintf(), but it might be for our
src/port/snprintf.c implementation and so not compatible with the
platform's sscanf().  This appears to be the explanation for buildfarm
member frogmouth's continuing unhappiness with the tzcode update.

Fortunately, in all of the places where zic is attempting to read into
an int64 variable, it's reading a year which certainly will fit just fine
into an int.  So make it read into an int with %d, and then cast or copy
as necessary.

8 years agoFix recovery_min_apply_delay test
Alvaro Herrera [Thu, 31 Mar 2016 18:41:18 +0000 (15:41 -0300)]
Fix recovery_min_apply_delay test

Previously this test was relying too much on WAL replay to occur in the
exact configured interval, which was unreliable on slow or overly busy
servers.  Use a custom loop instead of poll_query_until, which is
hopefully more reliable.

Per continued failures on buildfarm member hamster (which is probably
the only one running this test suite)

Author: Michaël Paquier

8 years agoSupport using index-only scans with partial indexes in more cases.
Tom Lane [Thu, 31 Mar 2016 18:48:56 +0000 (14:48 -0400)]
Support using index-only scans with partial indexes in more cases.

Previously, the planner would reject an index-only scan if any restriction
clause for its table used a column not available from the index, even
if that restriction clause would later be dropped from the plan entirely
because it's implied by the index's predicate.  This is a fairly common
situation for partial indexes because predicates using columns not included
in the index are often the most useful kind of predicate, and we have to
duplicate (or at least imply) the predicate in the WHERE clause in order
to get the index to be considered at all.  So index-only scans were
essentially unavailable with such partial indexes.

To fix, we have to do detection of implied-by-predicate clauses much
earlier in the planner.  This patch puts it in check_index_predicates
(nee check_partial_indexes), meaning it gets done for every partial index,
whereas we previously only considered this issue at createplan time,
so that the work was only done for an index actually selected for use.
That could result in a noticeable planning slowdown for queries against
tables with many partial indexes.  However, testing suggested that there
isn't really a significant cost, especially not with reasonable numbers
of partial indexes.  We do get a small additional benefit, which is that
cost_index is more accurate since it correctly discounts the evaluation
cost of clauses that will be removed.  We can also avoid considering such
clauses as potential indexquals, which saves useless matching cycles in
the case where the predicate columns aren't in the index, and prevents
generating bogus plans that double-count the clause's selectivity when
the columns are in the index.

Tomas Vondra and Kyotaro Horiguchi, reviewed by Kevin Grittner and
Konstantin Knizhnik, and whacked around a little by me

8 years agoFix broken variable declaration
Alvaro Herrera [Thu, 31 Mar 2016 02:39:15 +0000 (23:39 -0300)]
Fix broken variable declaration

Author: Konstantin Knizhnik

8 years agoBlind attempt at fixing Win32 issue on 24c5f1a103c
Alvaro Herrera [Thu, 31 Mar 2016 02:06:34 +0000 (23:06 -0300)]
Blind attempt at fixing Win32 issue on 24c5f1a103c

As best as I can tell, MyReplicationSlot needs to be PGDLLIMPORT in
order for the new test_slot_timelines test module to compile.

Per buildfarm

8 years agoUse proper format specifier %X/%X for LSN.
Fujii Masao [Thu, 31 Mar 2016 02:03:40 +0000 (11:03 +0900)]
Use proper format specifier %X/%X for LSN.