]> granicus.if.org Git - postgresql/log
postgresql
9 years agoDocs: fix claim that to_char('FM') removes trailing zeroes.
Tom Lane [Thu, 25 Jun 2015 14:44:03 +0000 (10:44 -0400)]
Docs: fix claim that to_char('FM') removes trailing zeroes.

Of course, what it removes is leading zeroes.  Seems to have been a thinko
in commit ffe92d15d53625d5ae0c23f4e1984ed43614a33d.  Noted by Hubert Depesz
Lubaczewski.

9 years agoAdd index terms for functions jsonb_set and jsonb_pretty.
Fujii Masao [Wed, 24 Jun 2015 13:30:19 +0000 (22:30 +0900)]
Add index terms for functions jsonb_set and jsonb_pretty.

9 years agoUpdate get_relation_info comment.
Robert Haas [Tue, 23 Jun 2015 14:08:30 +0000 (10:08 -0400)]
Update get_relation_info comment.

Thomas Munro

9 years agoAdd missing newline to debug-message.
Heikki Linnakangas [Tue, 23 Jun 2015 12:49:28 +0000 (15:49 +0300)]
Add missing newline to debug-message.

Michael Paquier

9 years agopg_rewind: Improve message wording
Peter Eisentraut [Tue, 23 Jun 2015 00:40:01 +0000 (20:40 -0400)]
pg_rewind: Improve message wording

9 years agopg_basebackup: Remove redundant newline in error message
Peter Eisentraut [Tue, 23 Jun 2015 00:39:41 +0000 (20:39 -0400)]
pg_basebackup: Remove redundant newline in error message

9 years agoImprove inheritance_planner()'s performance for large inheritance sets.
Tom Lane [Mon, 22 Jun 2015 22:53:27 +0000 (18:53 -0400)]
Improve inheritance_planner()'s performance for large inheritance sets.

Commit c03ad5602f529787968fa3201b35c119bbc6d782 introduced a planner
performance regression for UPDATE/DELETE on large inheritance sets.
It required copying the append_rel_list (which is of size proportional to
the number of inherited tables) once for each inherited table, thus
resulting in O(N^2) time and memory consumption.  While it's difficult to
avoid that in general, the extra work only has to be done for
append_rel_list entries that actually reference subquery RTEs, which
inheritance-set entries will not.  So we can buy back essentially all of
the loss in cases without subqueries in FROM; and even for those, the added
work is mainly proportional to the number of UNION ALL subqueries.

Back-patch to 9.2, like the previous commit.

Tom Lane and Dean Rasheed, per a complaint from Thomas Munro.

9 years agopsql: Add some tab completion for TABLESAMPLE.
Robert Haas [Mon, 22 Jun 2015 18:13:56 +0000 (14:13 -0400)]
psql: Add some tab completion for TABLESAMPLE.

Petr Jelinek, reviewed by Brendan Jurd

9 years agoTruncate strings in tarCreateHeader() with strlcpy(), not sprintf().
Noah Misch [Mon, 22 Jun 2015 00:04:36 +0000 (20:04 -0400)]
Truncate strings in tarCreateHeader() with strlcpy(), not sprintf().

This supplements the GNU libc bug #6530 workarounds introduced in commit
54cd4f04576833abc394e131288bf3dd7dcf4806.  On affected systems, a
tar-format pg_basebackup failed when some filename beneath the data
directory was not valid character data in the postmaster/walsender
locale.  Back-patch to 9.1, where pg_basebackup was introduced.  Extant,
bug-prone conversion specifications receive only ASCII bytes or involve
low-importance messages.

9 years agoAdd transforms to pg_get_object_address and friends
Alvaro Herrera [Sun, 21 Jun 2015 19:08:49 +0000 (16:08 -0300)]
Add transforms to pg_get_object_address and friends

This was missed when transforms were added by commit cac76582053ef8e.

Extracted from a larger patch
Author: Michael Paquier

9 years agoImprove multixact emergency autovacuum logic.
Andres Freund [Sun, 21 Jun 2015 16:57:28 +0000 (18:57 +0200)]
Improve multixact emergency autovacuum logic.

Previously autovacuum was not necessarily triggered if space in the
members slru got tight. The first problem was that the signalling was
tied to values in the offsets slru, but members can advance much
faster. Thats especially a problem if old sessions had been around that
previously prevented the multixact horizon to increase. Secondly the
skipping logic doesn't work if the database was restarted after
autovacuum was triggered - that knowledge is not preserved across
restart. This is especially a problem because it's a common
panic-reaction to restart the database if it gets slow to
anti-wraparound vacuums.

Fix the first problem by separating the logic for members from
offsets. Trigger autovacuum whenever a multixact crosses a segment
boundary, as the current member offset increases in irregular values, so
we can't use a simple modulo logic as for offsets.  Add a stopgap for
the second problem, by signalling autovacuum whenver ERRORing out
because of boundaries.

Discussion: 20150608163707.GD20772@alap3.anarazel.de

Backpatch into 9.3, where it became more likely that multixacts wrap
around.

9 years agoAdd missing check for wal_debug GUC.
Andres Freund [Sun, 21 Jun 2015 16:35:59 +0000 (18:35 +0200)]
Add missing check for wal_debug GUC.

9a20a9b2 added a new elog(), enabled when WAL_DEBUG is defined. The
other WAL_DEBUG dependant messages check for the wal_debug GUC, but this
one did not. While at it replace 'upto' with 'up to'.

Discussion: 20150610110253.GF3832@alap3.anarazel.de

Backpatch to 9.4, the first release containing 9a20a9b2.

9 years agoPL/Perl: Add alternative expected file for Perl 5.22
Peter Eisentraut [Sun, 21 Jun 2015 14:37:24 +0000 (10:37 -0400)]
PL/Perl: Add alternative expected file for Perl 5.22

9 years agoFix failure to copy setlocale() return value.
Noah Misch [Sat, 20 Jun 2015 16:09:29 +0000 (12:09 -0400)]
Fix failure to copy setlocale() return value.

POSIX permits setlocale() calls to invalidate any previous setlocale()
return values, but commit 5f538ad004aa00cf0881f179f0cde789aad4f47e
neglected to account for setlocale(LC_CTYPE, NULL) doing so.  The effect
was to set the LC_CTYPE environment variable to an unintended value.
pg_perm_setlocale() sets this variable to assist PL/Perl; without it,
Perl would undo PostgreSQL's locale settings.  The known-affected
configurations are 32-bit, release builds using Visual Studio 2012 or
Visual Studio 2013.  Visual Studio 2010 is unaffected, as were all
buildfarm-attested configurations.  In principle, this bug could leave
the wrong LC_CTYPE in effect after PL/Perl use, which could in turn
facilitate problems like corrupt tsvector datums.  No known platform
experiences that consequence, because PL/Perl on Windows does not use
this environment variable.

The bug has been user-visible, as early postmaster failure, on systems
with Windows ANSI code page set to CP936 for "Chinese (Simplified, PRC)"
and probably on systems using other multibyte code pages.
(SetEnvironmentVariable() rejects values containing character data not
valid under the Windows ANSI code page.)  Back-patch to 9.4, where the
faulty commit first appeared.

Reported by Didi Hu and 林鹏程.  Reviewed by Tom Lane, though this fix
strategy was not his first choice.

9 years agoRevert "Detect setlocale(LC_CTYPE, NULL) clobbering previous return values."
Noah Misch [Sat, 20 Jun 2015 16:08:48 +0000 (12:08 -0400)]
Revert "Detect setlocale(LC_CTYPE, NULL) clobbering previous return values."

This reverts commit b76e76be460a240e99c33f6fb470dd1d5fe01a2a.  The
buildfarm yielded no related failures.

9 years agoFix BRIN supported operators table
Alvaro Herrera [Sat, 20 Jun 2015 15:26:36 +0000 (12:26 -0300)]
Fix BRIN supported operators table

Some of the entries in the inclusion opclasses where missing operators,
and we had an entry for inet_inclusion_ops instead of
network_inclusion_ops.  Sort the operators within each opclass by
strategy number, just to make it easier to spot mistakes.

Also sort the rows by data type name, rather than OID.

9 years agoFix thinko in comment (launcher -> worker)
Alvaro Herrera [Sat, 20 Jun 2015 14:45:59 +0000 (11:45 -0300)]
Fix thinko in comment (launcher -> worker)

9 years agoIn immediate shutdown, postmaster should not exit till children are gone.
Tom Lane [Fri, 19 Jun 2015 18:23:39 +0000 (14:23 -0400)]
In immediate shutdown, postmaster should not exit till children are gone.

This adjusts commit 82233ce7ea42d6ba519aaec63008aff49da6c7af so that the
postmaster does not exit until all its child processes have exited, even
if the 5-second timeout elapses and we have to send SIGKILL.  There is no
great value in having the postmaster process quit sooner, and doing so can
mislead onlookers into thinking that the cluster is fully terminated when
actually some child processes still survive.

This effect might explain recent test failures on buildfarm member hamster,
wherein we failed to restart a cluster just after shutting it down with
"pg_ctl stop -m immediate".

I also did a bit of code review/beautification, including fixing a faulty
use of the Max() macro on a volatile expression.

Back-patch to 9.4.  In older branches, the postmaster never waited for
children to exit during immediate shutdowns, and changing that would be
too much of a behavioral change.

9 years agoClamp autovacuum launcher sleep time to 5 minutes
Alvaro Herrera [Fri, 19 Jun 2015 15:44:36 +0000 (12:44 -0300)]
Clamp autovacuum launcher sleep time to 5 minutes

This avoids the problem that it might go to sleep for an unreasonable
amount of time in unusual conditions like the server clock moving
backwards an unreasonable amount of time.

(Simply moving the server clock forward again doesn't solve the problem
unless you wake up the autovacuum launcher manually, say by sending it
SIGHUP).

Per trouble report from Prakash Itnal in
https://www.postgresql.org/message-id/CAHC5u79-UqbapAABH2t4Rh2eYdyge0Zid-X=Xz-ZWZCBK42S0Q@mail.gmail.com

Analyzed independently by Haribabu Kommi and Tom Lane.

9 years agoFix bogus range_table_mutator() logic for RangeTblEntry.tablesample.
Tom Lane [Fri, 19 Jun 2015 15:41:45 +0000 (11:41 -0400)]
Fix bogus range_table_mutator() logic for RangeTblEntry.tablesample.

Must make a copy of the TableSampleClause node; the previous coding
modified the input data structure in-place.

Petr Jelinek

9 years agoFix corner case in autovacuum-forcing logic for multixact wraparound.
Robert Haas [Fri, 19 Jun 2015 15:28:30 +0000 (11:28 -0400)]
Fix corner case in autovacuum-forcing logic for multixact wraparound.

Since find_multixact_start() relies on SimpleLruDoesPhysicalPageExist(),
and that function looks only at the on-disk state, it's possible for it
to fail to find a page that exists in the in-memory SLRU that has not
been written yet.  If that happens, SetOffsetVacuumLimit() will
erroneously decide to force emergency autovacuuming immediately.

We should probably fix find_multixact_start() to consider the data
cached in memory as well as on the on-disk state, but that's no excuse
for SetOffsetVacuumLimit() to be stupid about the case where it can
no longer read the value after having previously succeeded in doing so.

Report by Andres Freund.

9 years agoAdd PASSWORD to tab completions for CREATE/ALTER ROLE/USER/GROUP.
Robert Haas [Fri, 19 Jun 2015 15:11:22 +0000 (11:11 -0400)]
Add PASSWORD to tab completions for CREATE/ALTER ROLE/USER/GROUP.

Jeevan Chalke

9 years agoChange TAP test framework to not rely on having a chmod executable.
Robert Haas [Fri, 19 Jun 2015 14:46:30 +0000 (10:46 -0400)]
Change TAP test framework to not rely on having a chmod executable.

This might not work at all on Windows, and is not ever efficient.

Michael Paquier

9 years agoDetect setlocale(LC_CTYPE, NULL) clobbering previous return values.
Noah Misch [Wed, 17 Jun 2015 12:13:33 +0000 (08:13 -0400)]
Detect setlocale(LC_CTYPE, NULL) clobbering previous return values.

POSIX permits setlocale() calls to invalidate any previous setlocale()
return values.  Commit 5f538ad004aa00cf0881f179f0cde789aad4f47e
neglected to account for that.  In advance of fixing that bug, switch to
failing hard on affected configurations.  This is a planned temporary
commit to assay buildfarm-represented configurations.

9 years agoFix comment in fmgr.h to refer to actual function used.
Andrew Dunstan [Tue, 16 Jun 2015 03:21:03 +0000 (23:21 -0400)]
Fix comment in fmgr.h to refer to actual function used.

FunctionLookup() is long gone if it ever existed, and fmgr_info() is
what's now used, so the comments now reflect that.

9 years agoCheck for out of memory when allocating sqlca.
Michael Meskes [Mon, 15 Jun 2015 12:21:03 +0000 (14:21 +0200)]
Check for out of memory when allocating sqlca.

Patch by Michael Paquier

9 years agoFix memory leak in ecpglib's connect function.
Michael Meskes [Mon, 15 Jun 2015 12:20:09 +0000 (14:20 +0200)]
Fix memory leak in ecpglib's connect function.

Patch by Michael Paquier

9 years agorelease notes: fix Petr's name typos
Bruce Momjian [Sun, 14 Jun 2015 17:41:37 +0000 (13:41 -0400)]
release notes:  fix Petr's name typos

Report by Alvaro Herrera

9 years agodoc: Add note to pg_dump man page about pg_dumpall
Peter Eisentraut [Sun, 14 Jun 2015 01:45:56 +0000 (21:45 -0400)]
doc: Add note to pg_dump man page about pg_dumpall

suggested by Joshua Drake

9 years agoRemove stray character
Peter Eisentraut [Sun, 14 Jun 2015 01:41:34 +0000 (21:41 -0400)]
Remove stray character

9 years agorelease notes: consistently name "Alexander Shulgin"
Bruce Momjian [Sun, 14 Jun 2015 01:10:48 +0000 (21:10 -0400)]
release notes:  consistently name "Alexander Shulgin"

Report by Alvaro Herrera

9 years agorelease notes: move/remove/adjust items
Bruce Momjian [Sun, 14 Jun 2015 01:07:24 +0000 (21:07 -0400)]
release notes:  move/remove/adjust items

Report by Alvaro Herrera

9 years agorelease notes: add accent to Petr Jelínek last name
Bruce Momjian [Sun, 14 Jun 2015 01:00:30 +0000 (21:00 -0400)]
release notes:  add accent to Petr Jelínek last name

Report by Alvaro Herrera

9 years agorelease notes: remove mention of pg_basebackup non-compat
Bruce Momjian [Sun, 14 Jun 2015 00:56:30 +0000 (20:56 -0400)]
release notes:  remove mention of pg_basebackup non-compat

Report by Amit Kapila

9 years agorelease notes: add Petr Jelinek to JSON function item
Bruce Momjian [Sat, 13 Jun 2015 02:34:31 +0000 (22:34 -0400)]
release notes:  add Petr Jelinek to JSON function item

Report by Petr Jelinek

9 years agorelease notes: fixes from Fujii Masao
Bruce Momjian [Sat, 13 Jun 2015 02:31:17 +0000 (22:31 -0400)]
release notes:  fixes from Fujii Masao

Report by Fujii Masao

9 years agorelease notes: reorder hash performance authors, again
Bruce Momjian [Sat, 13 Jun 2015 02:25:30 +0000 (22:25 -0400)]
release notes:  reorder hash performance authors, again

Report by Robert Haas

9 years agorelease notes: reorder sort performance authors
Bruce Momjian [Sat, 13 Jun 2015 02:23:40 +0000 (22:23 -0400)]
release notes:  reorder sort performance authors

Report by Peter Geoghegan

9 years agorelease notes: split apart hash items
Bruce Momjian [Sat, 13 Jun 2015 02:16:08 +0000 (22:16 -0400)]
release notes:  split apart hash items

Report by Tom Lane, Robert Haas

9 years agorelease notes: add two optimizer items
Bruce Momjian [Sat, 13 Jun 2015 01:47:08 +0000 (21:47 -0400)]
release notes:  add two optimizer items

Report by Tom Lane

9 years agoFix "path" infrastructure bug affecting jsonb_set()
Andrew Dunstan [Fri, 12 Jun 2015 23:26:03 +0000 (19:26 -0400)]
Fix "path" infrastructure bug affecting jsonb_set()

jsonb_set() and other clients of the setPathArray() utility function
could get spurious results when an array integer subscript is provided
that is not within the range of int.

To fix, ensure that the value returned by strtol() within setPathArray()
is within the range of int;  when it isn't, assume an invalid input in
line with existing, similar cases.  The path-orientated operators that
appeared in PostgreSQL 9.3 and 9.4 do not call setPathArray(), and
already independently take this precaution, so no change there.

Peter Geoghegan

9 years agoFix failure to cover scalar-vs-rowtype cases in exec_stmt_return().
Tom Lane [Fri, 12 Jun 2015 17:44:06 +0000 (13:44 -0400)]
Fix failure to cover scalar-vs-rowtype cases in exec_stmt_return().

In commit 9e3ad1aac52454569393a947c06be0d301749362 I modified plpgsql
to use exec_stmt_return's simple-variables fast path in more cases.
However, I overlooked that there are really two different return
conventions in use here, depending on whether estate->retistuple is true,
and the existing fast-path code had only bothered to handle one of them.
So trying to return a scalar in a function returning composite, or vice
versa, could lead to unexpected error messages (typically "cache lookup
failed for type 0") or to a null-pointer-dereference crash.

In the DTYPE_VAR case, we can just throw error if retistuple is true,
corresponding to what happens in the general-expression code path that was
being used previously.  (Perhaps someday both of these code paths should
attempt a coercion, but today is not that day.)

In the REC and ROW cases, just hand the problem to exec_eval_datum()
when not retistuple.  Also clean up the ROW coding slightly so it looks
more like exec_eval_datum().

The previous commit also caused exec_stmt_return_next() to be used in
more cases, but that code seems to be OK as-is.

Per off-list report from Serge Rielau.  This bug is new in 9.5 so no need
to back-patch.

9 years agoImprove error message and hint for ALTER COLUMN TYPE can't-cast failure.
Tom Lane [Fri, 12 Jun 2015 15:54:03 +0000 (11:54 -0400)]
Improve error message and hint for ALTER COLUMN TYPE can't-cast failure.

We already tried to improve this once, but the "improved" text was rather
off-target if you had provided a USING clause.  Also, it seems helpful
to provide the exact text of a suggested USING clause, so users can just
copy-and-paste it when needed.  Per complaint from Keith Rarick and a
suggestion from Merlin Moncure.

Back-patch to 9.2 where the current wording was adopted.

9 years agoMake postmaster restart archiver soon after it dies, even during recovery.
Fujii Masao [Fri, 12 Jun 2015 14:11:51 +0000 (23:11 +0900)]
Make postmaster restart archiver soon after it dies, even during recovery.

After the archiver dies, postmaster tries to start a new one immediately.
But previously this could happen only while server was running normally
even though archiving was enabled always (i.e., archive_mode was set to
always). So the archiver running during recovery could not restart soon
after it died. This is an oversight in commit ffd3774.

This commit changes reaper(), postmaster's signal handler to cleanup
after a child process dies, so that it tries to a new archiver even during
recovery if necessary.

Patch by me. Review by Alvaro Herrera.

9 years agoFixed some memory leaks in ECPG.
Michael Meskes [Fri, 12 Jun 2015 12:52:55 +0000 (14:52 +0200)]
Fixed some memory leaks in ECPG.

Patch by Michael Paquier

9 years agoFix intoasc() in Informix compat lib. This function used to be a noop.
Michael Meskes [Fri, 12 Jun 2015 12:50:47 +0000 (14:50 +0200)]
Fix intoasc() in Informix compat lib. This function used to be a noop.

Patch by Michael Paquier

9 years agoFix alphabetization in catalogs.sgml.
Fujii Masao [Fri, 12 Jun 2015 03:59:29 +0000 (12:59 +0900)]
Fix alphabetization in catalogs.sgml.

System catalogs and views should be listed alphabetically
in catalog.sgml, but only pg_file_settings view not.

This patch also fixes typos in pg_file_settings comments.

9 years agoClean up useless mention of RMGRDESCSOURCES in pg_rewind Makefile.
Fujii Masao [Fri, 12 Jun 2015 03:32:48 +0000 (12:32 +0900)]
Clean up useless mention of RMGRDESCSOURCES in pg_rewind Makefile.

RMGRDESCSOURCES is defined and used only in pg_xlogdump Makefile,
but pg_rewind Makefile mentioned it as extra files to remove in "make clean".
This patch removes that useless mention from pg_rewind Makefile.

Michael Paquier

9 years agorelease notes: add links to doc sections
Bruce Momjian [Fri, 12 Jun 2015 03:04:46 +0000 (23:04 -0400)]
release notes:  add links to doc sections

9 years agorelease notes: update hash item
Bruce Momjian [Thu, 11 Jun 2015 15:32:32 +0000 (11:32 -0400)]
release notes:  update hash item

Report by Tomas Vondra

9 years agorelease notes: move pg_buffercache item to the right section
Bruce Momjian [Thu, 11 Jun 2015 15:13:49 +0000 (11:13 -0400)]
release notes:  move pg_buffercache item to the right section

Report by Amit Langote

9 years agorelease notes: implement suggestions
Bruce Momjian [Thu, 11 Jun 2015 15:11:43 +0000 (11:11 -0400)]
release notes:  implement suggestions

Report by Michael Paquier

9 years agorelease notes: explain meaning of pg_stat_get_snapshot_timestamp()
Bruce Momjian [Thu, 11 Jun 2015 14:58:38 +0000 (10:58 -0400)]
release notes:  explain meaning of pg_stat_get_snapshot_timestamp()

Report by Michael Paquier

9 years agorelease notes: update for pg_basebackup in tar format
Bruce Momjian [Thu, 11 Jun 2015 14:51:18 +0000 (10:51 -0400)]
release notes:  update for pg_basebackup in tar format

Report by Amit Kapila

9 years agoRename jsonb - text[] operator to #- to avoid ambiguity.
Andrew Dunstan [Thu, 11 Jun 2015 14:06:58 +0000 (10:06 -0400)]
Rename jsonb - text[] operator to #- to avoid ambiguity.

Following recent discussion  on -hackers. The underlying function is
also renamed to jsonb_delete_path. The regression tests now don't need
ugly type casts to avoid the ambiguity, so they are also removed.

Catalog version bumped.

9 years agoFix some issues in pg_rewind.
Fujii Masao [Thu, 11 Jun 2015 13:31:18 +0000 (22:31 +0900)]
Fix some issues in pg_rewind.

* Remove invalid option character "N" from the third argument (valid option
string) of getopt_long().

* Use pg_free() or pfree() to free the memory allocated by pg_malloc() or
palloc() instead of always using free().

* Assume problem is no disk space if write() fails but doesn't set errno.

* Fix several typos.

Patch by me. Review by Michael Paquier.

9 years agoFirst draft of 9.5 release notes
Bruce Momjian [Thu, 11 Jun 2015 04:08:55 +0000 (00:08 -0400)]
First draft of 9.5 release notes

9 years agodoc: Use "connections" instead of "slots" to avoid confusion
Peter Eisentraut [Thu, 11 Jun 2015 01:34:03 +0000 (21:34 -0400)]
doc: Use "connections" instead of "slots" to avoid confusion

The text was written before replication slots existed, but now "slot" is
best not used for anything else in the space of replication.

9 years agodoc: Fix typo
Peter Eisentraut [Thu, 11 Jun 2015 01:33:35 +0000 (21:33 -0400)]
doc: Fix typo

9 years agoFix typo
Peter Eisentraut [Thu, 11 Jun 2015 01:30:17 +0000 (21:30 -0400)]
Fix typo

9 years agodoc: Call xmllint for validity also in the fop build
Peter Eisentraut [Wed, 10 Jun 2015 23:54:28 +0000 (19:54 -0400)]
doc: Call xmllint for validity also in the fop build

This was somehow missed in commit
5d93ce2d0c619ba1b408eb749715e7223e23f6ae.

9 years agoFix typo in comment.
Kevin Grittner [Wed, 10 Jun 2015 22:03:56 +0000 (17:03 -0500)]
Fix typo in comment.

Backpatch to 9.4 to minimize possible conflicts.

9 years agodocs: update release note regex suggestions
Bruce Momjian [Wed, 10 Jun 2015 20:33:46 +0000 (16:33 -0400)]
docs:  update release note regex suggestions

9 years agoFix typo in comment.
Fujii Masao [Wed, 10 Jun 2015 06:26:02 +0000 (15:26 +0900)]
Fix typo in comment.

David Rowley

9 years agoRelease notes for 9.4.4, 9.3.9, 9.2.13, 9.1.18, 9.0.22.
Tom Lane [Tue, 9 Jun 2015 18:33:43 +0000 (14:33 -0400)]
Release notes for 9.4.4, 9.3.9, 9.2.13, 9.1.18, 9.0.22.

9 years agoReport more information if pg_perm_setlocale() fails at startup.
Tom Lane [Tue, 9 Jun 2015 17:37:08 +0000 (13:37 -0400)]
Report more information if pg_perm_setlocale() fails at startup.

We don't know why a few Windows users have seen this fail, but the
taciturnity of the error message certainly isn't helping debug it.
Let's at least find out which LC category isn't working.

9 years agoFirst-draft release notes for 9.4.4, 9.3.9, 9.2.13, 9.1.18, 9.0.22.
Tom Lane [Tue, 9 Jun 2015 17:07:15 +0000 (13:07 -0400)]
First-draft release notes for 9.4.4, 9.3.9, 9.2.13, 9.1.18, 9.0.22.

9 years agoFix typos
Alvaro Herrera [Mon, 8 Jun 2015 18:35:43 +0000 (15:35 -0300)]
Fix typos

tablesapce -> tablespace
there -> their

These were introduced in 72d422a52, so no need to backpatch.

9 years agoRefactor WAL segment copying code.
Fujii Masao [Mon, 8 Jun 2015 18:03:24 +0000 (03:03 +0900)]
Refactor WAL segment copying code.

* Remove unused argument "dstfname" and related code from XLogFileCopy().

* Previously XLogFileCopy() returned a pstrdup'd string so that
InstallXLogFileSegment() used it later. Since the pstrdup'd string was never
free'd, there could be a risk of memory leak. It was almost harmless because
the startup process exited just after calling XLogFileCopy(), it existed.
This commit changes XLogFileCopy() so that it directly calls
InstallXLogFileSegment() and doesn't call pstrdup() at all. Which fixes that
memory leak problem.

* Extend InstallXLogFileSegment() so that the caller can specify the log level.
Which allows us to emit an error when InstallXLogFileSegment() fails a disk
file access like link() and rename(). Previously it was always logged with
LOG level and additionally needed to be logged with ERROR when we wanted
to treat it as an error.

Michael Paquier

9 years agoAllow HotStandbyActiveInReplay() to be called in single user mode.
Andres Freund [Sun, 7 Jun 2015 22:30:26 +0000 (00:30 +0200)]
Allow HotStandbyActiveInReplay() to be called in single user mode.

HotStandbyActiveInReplay, introduced in 061b079f, only allowed WAL
replay to happen in the startup process, missing the single user case.

This buglet is fairly harmless as it only causes problems when single
user mode in an assertion enabled build is used to replay a btree vacuum
record.

Backpatch to 9.2. 061b079f was backpatched further, but the assertion
was not.

9 years agoClarify documentation of jsonb - text
Andrew Dunstan [Mon, 8 Jun 2015 01:31:52 +0000 (21:31 -0400)]
Clarify documentation of jsonb - text

Peter Geoghegan

9 years agoDesupport jsonb subscript deletion on objects
Andrew Dunstan [Mon, 8 Jun 2015 00:46:00 +0000 (20:46 -0400)]
Desupport jsonb subscript deletion on objects

Supporting deletion of JSON pairs within jsonb objects using an
array-style integer subscript allowed for surprising outcomes.  This was
mostly due to the implementation-defined ordering of pairs within
objects for jsonb.

It also seems desirable to make jsonb integer subscript deletion
consistent with the 9.4 era general purpose integer subscripting
operator for jsonb (although that operator returns NULL when an object
is encountered, while we prefer here to throw an error).

Peter Geoghegan, following discussion on -hackers.

9 years agodoc: Fix broken links in FOP build
Peter Eisentraut [Mon, 8 Jun 2015 00:27:27 +0000 (20:27 -0400)]
doc: Fix broken links in FOP build

FOP doesn't handle links to table rows, so put the link to a cell
instead.

9 years agoUse a safer method for determining whether relcache init file is stale.
Tom Lane [Sun, 7 Jun 2015 19:32:09 +0000 (15:32 -0400)]
Use a safer method for determining whether relcache init file is stale.

When we invalidate the relcache entry for a system catalog or index, we
must also delete the relcache "init file" if the init file contains a copy
of that rel's entry.  The old way of doing this relied on a specially
maintained list of the OIDs of relations present in the init file: we made
the list either when reading the file in, or when writing the file out.
The problem is that when writing the file out, we included only rels
present in our local relcache, which might have already suffered some
deletions due to relcache inval events.  In such cases we correctly decided
not to overwrite the real init file with incomplete data --- but we still
used the incomplete initFileRelationIds list for the rest of the current
session.  This could result in wrong decisions about whether the session's
own actions require deletion of the init file, potentially allowing an init
file created by some other concurrent session to be left around even though
it's been made stale.

Since we don't support changing the schema of a system catalog at runtime,
the only likely scenario in which this would cause a problem in the field
involves a "vacuum full" on a catalog concurrently with other activity, and
even then it's far from easy to provoke.  Remarkably, this has been broken
since 2002 (in commit 786340441706ac1957a031f11ad1c2e5b6e18314), but we had
never seen a reproducible test case until recently.  If it did happen in
the field, the symptoms would probably involve unexpected "cache lookup
failed" errors to begin with, then "could not open file" failures after the
next checkpoint, as all accesses to the affected catalog stopped working.
Recovery would require manually removing the stale "pg_internal.init" file.

To fix, get rid of the initFileRelationIds list, and instead consult
syscache.c's list of relations used in catalog caches to decide whether a
relation is included in the init file.  This should be a tad more efficient
anyway, since we're replacing linear search of a list with ~100 entries
with a binary search.  It's a bit ugly that the init file contents are now
so directly tied to the catalog caches, but in practice that won't make
much difference.

Back-patch to all supported branches.

9 years agoGet rid of a //-style comment.
Tom Lane [Fri, 5 Jun 2015 21:04:07 +0000 (17:04 -0400)]
Get rid of a //-style comment.

Not sure how "//XXX" got into a committed patch in the first place,
as it's both content-free and against project style.  pgindent made a
bit of a hash of it, too.

Going forward, we should have at least one buildfarm member using
"gcc -ansi" to catch such things, at least till such time as we
decide the project target language isn't C90 any more.  I've turned
this option on on dromedary.

9 years agoFix incorrect order of database-locking operations in InitPostgres().
Tom Lane [Fri, 5 Jun 2015 17:22:27 +0000 (13:22 -0400)]
Fix incorrect order of database-locking operations in InitPostgres().

We should set MyProc->databaseId after acquiring the per-database lock,
not beforehand.  The old way risked deadlock against processes trying to
copy or delete the target database, since they would first acquire the lock
and then wait for processes with matching databaseId to exit; that left a
window wherein an incoming process could set its databaseId and then block
on the lock, while the other process had the lock and waited in vain for
the incoming process to exit.

CountOtherDBBackends() would time out and fail after 5 seconds, so this
just resulted in an unexpected failure not a permanent lockup, but it's
still annoying when it happens.  A real-world example of a use-case is that
short-duration connections to a template database should not cause CREATE
DATABASE to fail.

Doing it in the other order should be fine since the contract has always
been that processes searching the ProcArray for a database ID must hold the
relevant per-database lock while searching.  Thus, this actually removes
the former race condition that required an assumption that storing to
MyProc->databaseId is atomic.

It's been like this for a long time, so back-patch to all active branches.

9 years agoCope with possible failure of the oldest MultiXact to exist.
Robert Haas [Fri, 5 Jun 2015 12:34:52 +0000 (08:34 -0400)]
Cope with possible failure of the oldest MultiXact to exist.

Recent commits, mainly b69bf30b9bfacafc733a9ba77c9587cf54d06c0c and
53bb309d2d5a9432d2602c93ed18e58bd2924e15, introduced mechanisms to
protect against wraparound of the MultiXact member space: the number
of multixacts that can exist at one time is limited to 2^32, but the
total number of members in those multixacts is also limited to 2^32,
and older code did not take care to enforce the second limit,
potentially allowing old data to be overwritten while it was still
needed.

Unfortunately, these new mechanisms failed to account for the fact
that the code paths in which they run might be executed during
recovery or while the cluster was in an inconsistent state.  Also,
they failed to account for the fact that users who used pg_upgrade
to upgrade a PostgreSQL version between 9.3.0 and 9.3.4 might have
might oldestMultiXid = 1 in the control file despite the true value
being larger.

To fix these problems, first, avoid unnecessarily examining the
mmembers of MultiXacts when the cluster is not known to be consistent.
TruncateMultiXact has done this for a long time, and this patch does
not fix that.  But the new calls used to prevent member wraparound
are not needed until we reach normal running, so avoid calling them
earlier.  (SetMultiXactIdLimit is actually called before InRecovery
is set, so we can't rely on that; we invent our own multixact-specific
flag instead.)

Second, make failure to look up the members of a MultiXact a non-fatal
error.  Instead, if we're unable to determine the member offset at
which wraparound would occur, postpone arming the member wraparound
defenses until we are able to do so.  If we're unable to determine the
member offset that should force autovacuum, force it continuously
until we are able to do so.  If we're unable to deterine the member
offset at which we should truncate the members SLRU, log a message and
skip truncation.

An important consequence of these changes is that anyone who does have
a bogus oldestMultiXid = 1 value in pg_control will experience
immediate emergency autovacuuming when upgrading to a release that
contains this fix.  The release notes should highlight this fact.  If
a user has no pg_multixact/offsets/0000 file, but has oldestMultiXid = 1
in the control file, they may wish to vacuum any tables with
relminmxid = 1 prior to upgrading in order to avoid an immediate
emergency autovacuum after the upgrade.  This must be done with a
PostgreSQL version 9.3.5 or newer and with vacuum_multixact_freeze_min_age
and vacuum_multixact_freeze_table_age set to 0.

This patch also adds an additional log message at each database server
startup, indicating either that protections against member wraparound
have been engaged, or that they have not.  In the latter case, once
autovacuum has advanced oldestMultiXid to a sane value, the message
indicating that the guards have been engaged will appear at the next
checkpoint.  A few additional messages have also been added at the DEBUG1
level so that the correct operation of this code can be properly audited.

Along the way, this patch fixes another, related bug in TruncateMultiXact
that has existed since PostgreSQL 9.3.0: when no MultiXacts exist at
all, the truncation code looks up NextMultiXactId, which doesn't exist
yet.  This can lead to TruncateMultiXact removing every file in
pg_multixact/offsets instead of keeping one around, as it should.
This in turn will cause the database server to refuse to start
afterwards.

Patch by me.  Review by Álvaro Herrera, Andres Freund, Noah Misch, and
Thomas Munro.

9 years agodoc: Session identifiers truncate, not round, the backend start time.
Robert Haas [Thu, 4 Jun 2015 21:57:39 +0000 (17:57 -0400)]
doc: Session identifiers truncate, not round, the backend start time.

Joel Jacobson

9 years agodocs: Fix list of object types pg_table_is_visible() can handle.
Robert Haas [Thu, 4 Jun 2015 21:48:00 +0000 (17:48 -0400)]
docs: Fix list of object types pg_table_is_visible() can handle.

Materialized views and foreign tables were missing from the list,
probably because they are newer than the other object types that were
mentioned.

Etsuro Fujita

9 years agoSecond try at stabilizing query plans in rowsecurity regression test.
Tom Lane [Thu, 4 Jun 2015 20:42:23 +0000 (16:42 -0400)]
Second try at stabilizing query plans in rowsecurity regression test.

This reverts commit 5cdf25e16843dff33dbc2ddc02941458032e3ad4,
which was almost immediately proven insufficient by the buildfarm.

On second thought, the tables involved are not large enough that
autovacuum or autoanalyze would notice them; what seems far more
likely to be the culprit is the database-wide "vacuum analyze"
in the concurrent gist test.  That thing has given us one headache
too many, so get rid of it in favor of targeted vacuuming of that
test's own tables only.

9 years agoFix brin regression test so it actually tests cidr.
Tom Lane [Thu, 4 Jun 2015 19:24:22 +0000 (15:24 -0400)]
Fix brin regression test so it actually tests cidr.

The problem noted in my previous commit was simpler than I thought:
we weren't getting an index plan because the column wasn't indexed.

9 years agoTighten the per-operator testing done in brin regression test.
Tom Lane [Thu, 4 Jun 2015 18:39:52 +0000 (14:39 -0400)]
Tighten the per-operator testing done in brin regression test.

Verify that the number of matches is exactly what it should be, not just
that it not be zero.  This should help us detect any environment-dependent
issues.

Also, verify that we're getting the expected type of scan plan (either
bitmap or seqscan as appropriate).  Right now, this is failing on the
cidrcol test cases, as shown in the output file.  I'll look into that
in a bit, but it seems good to commit this as-is temporarily to verify
that it behaves as expected on the buildfarm.

9 years agoFix brin "char" test to actually test what it meant to test.
Tom Lane [Thu, 4 Jun 2015 17:50:32 +0000 (13:50 -0400)]
Fix brin "char" test to actually test what it meant to test.

Casting to char, without quotes, does not give the same results as casting
to "char".  That meant we were not testing the brin "char" paths at all,
since we ended up with a text operator not a "char" operator.

9 years agoStabilize results of brin regression test.
Tom Lane [Thu, 4 Jun 2015 17:46:34 +0000 (13:46 -0400)]
Stabilize results of brin regression test.

This test used seqscans on tenk1, with LIMIT, to build test data.
That works most of the time, but if the synchronized-seqscan logic
kicks in, we get varying test data.  This seems likely to explain
the erratic test failures on buildfarm member chipmunk, which uses
smaller-than-default shared_buffers.  To fix, add ORDER BY clauses to
force the ordering to be what it was implicitly being assumed to be.

Peter Geoghegan had noticed this with respect to one of the trouble
spots, though not the ones actually causing the chipmunk issue.

9 years agoStabilize query plans in rowsecurity regression test.
Tom Lane [Thu, 4 Jun 2015 14:37:06 +0000 (10:37 -0400)]
Stabilize query plans in rowsecurity regression test.

Some recent buildfarm failures can be explained by supposing that
autovacuum or autoanalyze fired on the tables created by this test,
resulting in plan changes.  Do a proactive VACUUM ANALYZE on the
test's principal tables to try to forestall such changes.

9 years agoRemove -i/--ignore-version option from pg_dump, pg_dumpall and pg_restore.
Fujii Masao [Thu, 4 Jun 2015 10:54:43 +0000 (19:54 +0900)]
Remove -i/--ignore-version option from pg_dump, pg_dumpall and pg_restore.

The commit c22ed3d523782c43836c163c16fa5a7bb3912826 turned
the -i/--ignore-version options into no-ops and marked as deprecated.
Considering we shipped that in 8.4, it's time to remove all trace of
those switches, per discussion. We'd still have to wait a couple releases
before it'd be safe to use -i for something else, but it'd be a start.

9 years agoFix some issues in pg_class.relminmxid and pg_database.datminmxid documentation.
Fujii Masao [Thu, 4 Jun 2015 04:22:49 +0000 (13:22 +0900)]
Fix some issues in pg_class.relminmxid and pg_database.datminmxid documentation.

- Correct the name of directory which those catalog columns allow to be shrunk.
- Correct the name of symbol which is used as the value of pg_class.relminmxid
  when the relation is not a table.
- Fix "ID ID" typo.

Backpatch to 9.3 where those cataog columns were introduced.

9 years agodoc: Fix PDF build with FOP
Peter Eisentraut [Thu, 4 Jun 2015 00:19:47 +0000 (20:19 -0400)]
doc: Fix PDF build with FOP

Because of a bug in the DocBook XSL FO style sheet, an xref to a
varlistentry whose term includes an indexterm fails to build.  One such
instance was introduced in commit
5086dfceba79ecd5d1eb28b8f4ed5221838ff3a6.  Fix by adding the upstream
bug fix to our customization layer.

9 years agoFix some questionable edge-case behaviors in add_path() and friends.
Tom Lane [Wed, 3 Jun 2015 22:02:39 +0000 (18:02 -0400)]
Fix some questionable edge-case behaviors in add_path() and friends.

add_path_precheck was doing exact comparisons of path costs, but it really
needs to do them fuzzily to be sure it won't reject paths that could
survive add_path's comparisons.  (This can only matter if the initial cost
estimate is very close to the final one, but that turns out to often be
true.)

Also, it should ignore startup cost for this purpose if and only if
compare_path_costs_fuzzily would do so.  The previous coding always ignored
startup cost for parameterized paths, which is wrong as of commit
3f59be836c555fa6; it could result in improper early rejection of paths that
we care about for SEMI/ANTI joins.  It also always considered startup cost
for unparameterized paths, which is just as wrong though the only effect is
to waste planner cycles on paths that can't survive.  Instead, it should
consider startup cost only when directed to by the consider_startup/
consider_param_startup relation flags.

Likewise, compare_path_costs_fuzzily should have symmetrical behavior
for parameterized and unparameterized paths.  In this case, the best
answer seems to be that after establishing that total costs are fuzzily
equal, we should compare startup costs whether or not the consider_xxx
flags are on.  That is what it's always done for unparameterized paths,
so let's make the behavior for parameterized  paths match.

These issues were noted while developing the SEMI/ANTI join costing fix
of commit 3f59be836c555fa6, but we chose not to back-patch these fixes,
because they can cause changes in the planner's choices among
nearly-same-cost plans.  (There is in fact one minor change in plan choice
within the core regression tests.)  Destabilizing plan choices in back
branches without very clear improvements is frowned on, so we'll just fix
this in HEAD.

9 years agoFix planner's cost estimation for SEMI/ANTI joins with inner indexscans.
Tom Lane [Wed, 3 Jun 2015 15:58:47 +0000 (11:58 -0400)]
Fix planner's cost estimation for SEMI/ANTI joins with inner indexscans.

When the inner side of a nestloop SEMI or ANTI join is an indexscan that
uses all the join clauses as indexquals, it can be presumed that both
matched and unmatched outer rows will be processed very quickly: for
matched rows, we'll stop after fetching one row from the indexscan, while
for unmatched rows we'll have an indexscan that finds no matching index
entries, which should also be quick.  The planner already knew about this,
but it was nonetheless charging for at least one full run of the inner
indexscan, as a consequence of concerns about the behavior of materialized
inner scans --- but those concerns don't apply in the fast case.  If the
inner side has low cardinality (many matching rows) this could make an
indexscan plan look far more expensive than it actually is.  To fix,
rearrange the work in initial_cost_nestloop/final_cost_nestloop so that we
don't add the inner scan cost until we've inspected the indexquals, and
then we can add either the full-run cost or just the first tuple's cost as
appropriate.

Experimentation with this fix uncovered another problem: add_path and
friends were coded to disregard cheap startup cost when considering
parameterized paths.  That's usually okay (and desirable, because it thins
the path herd faster); but in this fast case for SEMI/ANTI joins, it could
result in throwing away the desired plain indexscan path in favor of a
bitmap scan path before we ever get to the join costing logic.  In the
many-matching-rows cases of interest here, a bitmap scan will do a lot more
work than required, so this is a problem.  To fix, add a per-relation flag
consider_param_startup that works like the existing consider_startup flag,
but applies to parameterized paths, and set it for relations that are the
inside of a SEMI or ANTI join.

To make this patch reasonably safe to back-patch, care has been taken to
avoid changing the planner's behavior except in the very narrow case of
SEMI/ANTI joins with inner indexscans.  There are places in
compare_path_costs_fuzzily and add_path_precheck that are not terribly
consistent with the new approach, but changing them will affect planner
decisions at the margins in other cases, so we'll leave that for a
HEAD-only fix.

Back-patch to 9.3; before that, the consider_startup flag didn't exist,
meaning that the second aspect of the patch would be too invasive.

Per a complaint from Peter Holzer and analysis by Tomas Vondra.

9 years agoMinor improvement to txid_current() documentation.
Fujii Masao [Wed, 3 Jun 2015 03:12:48 +0000 (12:12 +0900)]
Minor improvement to txid_current() documentation.

Michael Paquier, reviewed by Christoph Berg and Naoya Anzai

9 years agoRelease notes for 9.4.3, 9.3.8, 9.2.12, 9.1.17, 9.0.21.
Tom Lane [Mon, 1 Jun 2015 17:27:43 +0000 (13:27 -0400)]
Release notes for 9.4.3, 9.3.8, 9.2.12, 9.1.17, 9.0.21.

Also sneak entries for commits 97ff2a564 et al into the sections for
the previous releases in the relevant branches.  Those fixes did go out
in the previous releases, but missed getting documented.

9 years agopgindent: add typedef blog URL
Bruce Momjian [Mon, 1 Jun 2015 15:27:30 +0000 (11:27 -0400)]
pgindent:  add typedef blog URL

9 years agoAvoid naming a variable "new", and remove bogus initializer.
Andrew Dunstan [Mon, 1 Jun 2015 02:56:53 +0000 (22:56 -0400)]
Avoid naming a variable "new", and remove bogus initializer.

Per gripe from Tom Lane.

9 years agoAdd a couple of missing JsonbValue type initialisers.
Andrew Dunstan [Mon, 1 Jun 2015 02:51:58 +0000 (22:51 -0400)]
Add a couple of missing JsonbValue type initialisers.

9 years agoRename jsonb_replace to jsonb_set and allow it to add new values
Andrew Dunstan [Mon, 1 Jun 2015 00:34:10 +0000 (20:34 -0400)]
Rename jsonb_replace to jsonb_set and allow it to add new values

The function is given a fourth parameter, which defaults to true. When
this parameter is true, if the last element of the path is missing
in the original json, jsonb_set creates it in the result and assigns it
the new value. If it is false then the function does nothing unless all
elements of the path are present, including the last.

Based on some original code from Dmitry Dolgov, heavily modified by me.

Catalog version bumped.

9 years agoMake Python tests more portable
Peter Eisentraut [Sun, 31 May 2015 11:10:45 +0000 (07:10 -0400)]
Make Python tests more portable

Newer Python versions randomize the hash seed for dictionaries,
resulting in a random output order, which messes up the regression test
diffs.

Instead, use Python assert to compare the dictionaries with their
expected value.

9 years agopg_upgrade: add missing period in C comment
Bruce Momjian [Fri, 29 May 2015 21:44:14 +0000 (17:44 -0400)]
pg_upgrade:  add missing period in C comment

9 years agoinitdb -S should now have an explicit check that $PGDATA is valid.
Tom Lane [Fri, 29 May 2015 21:02:58 +0000 (17:02 -0400)]
initdb -S should now have an explicit check that $PGDATA is valid.

The fsync code from the backend essentially assumes that somebody's already
validated PGDATA, at least to the extent of it being a readable directory.
That's safe enough for initdb's normal code path too, but "initdb -S"
doesn't have any other processing at all that touches the target directory.
To have reasonable error-case behavior, add a pg_check_dir call.
Per gripe from Peter E.

9 years agoRemove special cases for ETXTBSY from new fsync'ing logic.
Tom Lane [Fri, 29 May 2015 19:11:36 +0000 (15:11 -0400)]
Remove special cases for ETXTBSY from new fsync'ing logic.

The argument that this is a sufficiently-expected case to be silently
ignored seems pretty thin.  Andres had brought it up back when we were
still considering that most fsync failures should be hard errors, and it
probably would be legit not to fail hard for ETXTBSY --- but the same is
true for EROFS and other cases, which is why we gave up on hard failures.
ETXTBSY is surely not a normal case, so logging the failure seems fine
from here.