]> granicus.if.org Git - postgresql/log
postgresql
9 years agopsql: complain if pg_dump custom-format is detected
Alvaro Herrera [Fri, 24 Oct 2014 10:14:09 +0000 (07:14 -0300)]
psql: complain if pg_dump custom-format is detected

Apparently, this is a very common mistake for users to make; it is
better to have it fail reasonably rather than throw potentially a large
number of errors.  Since we have a magic string at the start of the
file, we can detect the case easily and there's no other possible useful
behavior anyway.

Author: Craig Ringer

9 years agoUpdate README.tuplock
Alvaro Herrera [Thu, 23 Oct 2014 23:51:58 +0000 (20:51 -0300)]
Update README.tuplock

This file was documenting an older version of patch 0ac5ad5134; update
it to match what was really committed

Author: Florian Pflug

9 years agoIn type_sanity, check I/O functions of built-in types are not volatile.
Tom Lane [Thu, 23 Oct 2014 19:59:40 +0000 (15:59 -0400)]
In type_sanity, check I/O functions of built-in types are not volatile.

We have a project policy that I/O functions must not be volatile, as per
commit aab353a60b95aadc00f81da0c6d99bde696c4b75, but we weren't doing
anything to enforce that.  In most usage the marking of the function
doesn't matter as long as its behavior is sane --- but I/O casts can
expose the marking as user-visible behavior, as per today's complaint
from Joe Van Dyk about contrib/ltree.

This test as such will only protect us against future errors in built-in
data types.  To catch the same error in contrib or third-party types,
perhaps we should make CREATE TYPE complain?  But that's a separate
issue from enforcing the policy for built-in types.

9 years agoImprove ispell dictionary's defenses against bad affix files.
Tom Lane [Thu, 23 Oct 2014 17:11:28 +0000 (13:11 -0400)]
Improve ispell dictionary's defenses against bad affix files.

Don't crash if an ispell dictionary definition contains flags but not
any compound affixes.  (This isn't a security issue since only superusers
can install affix files, but still it's a bad thing.)

Also, be more careful about detecting whether an affix-file FLAG command
is old-format (ispell) or new-format (myspell/hunspell).  And change the
error message about mixed old-format and new-format commands into something
intelligible.

Per bug #11770 from Emre Hasegeli.  Back-patch to all supported branches.

9 years agoPerform less setup work for AFTER triggers at transaction start.
Robert Haas [Thu, 23 Oct 2014 16:33:02 +0000 (12:33 -0400)]
Perform less setup work for AFTER triggers at transaction start.

Testing reveals that the memory allocation we do at transaction start
has small but measurable overhead on simple transactions.  To cut
down on that overhead, defer some of that work to the point when
AFTER triggers are first used, thus avoiding it altogether if they
never are.

Patch by me.  Review by Andres Freund.

9 years agoRemove the unused argument of PSQLexec().
Fujii Masao [Thu, 23 Oct 2014 13:33:56 +0000 (22:33 +0900)]
Remove the unused argument of PSQLexec().

This commit simply removes the second argument of PSQLexec that was
set to the same value everywhere. Comments and code blocks related
to this parameter are removed.

Noticed by Heikki Linnakangas, reviewed by Michael Paquier

9 years agoAdd a function to get the authenticated user ID.
Robert Haas [Thu, 23 Oct 2014 12:18:45 +0000 (08:18 -0400)]
Add a function to get the authenticated user ID.

Previously, this was not exposed outside of miscinit.c.  It is needed
for the pending pg_background patch, and will also be needed for
parallelism.  Without it, there's no way for a background worker to
re-create the exact authentication environment that was present in the
process that started it, which could lead to security exposures.

9 years agoPrevent the already-archived WAL file from being archived again.
Fujii Masao [Thu, 23 Oct 2014 07:21:27 +0000 (16:21 +0900)]
Prevent the already-archived WAL file from being archived again.

Previously the archive recovery always created .ready file for
the last WAL file of the old timeline at the end of recovery even when
it's restored from the archive and has .done file. That is, there was
the case where the WAL file had both .ready and .done files.
This caused the already-archived WAL file to be archived again.

This commit prevents the archive recovery from creating .ready file
for the last WAL file if it has .done file, in order to prevent it from
being archived again.

This bug was added when cascading replication feature was introduced,
i.e., the commit 5286105800c7d5902f98f32e11b209c471c0c69c.
So, back-patch to 9.2, where cascading replication was added.

Reviewed by Michael Paquier

9 years agoMinimize calls of pg_class_aclcheck to minimum necessary
Peter Eisentraut [Thu, 23 Oct 2014 01:41:43 +0000 (21:41 -0400)]
Minimize calls of pg_class_aclcheck to minimum necessary

In a couple of code paths, pg_class_aclcheck is called in succession
with multiple different modes set.  This patch combines those modes to
have a single call of this function and reduce a bit process overhead
for permission checking.

Author: Michael Paquier <michael@otacoo.com>
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
9 years agoAdd tests for sequence privileges
Peter Eisentraut [Thu, 23 Oct 2014 01:39:07 +0000 (21:39 -0400)]
Add tests for sequence privileges

9 years agoEnsure libpq reports a suitable error message on unexpected socket EOF.
Tom Lane [Wed, 22 Oct 2014 22:41:44 +0000 (18:41 -0400)]
Ensure libpq reports a suitable error message on unexpected socket EOF.

The EOF-detection logic in pqReadData was a bit confused about who should
set up the error message in case the kernel gives us read-ready-but-no-data
rather than ECONNRESET or some other explicit error condition.  Since the
whole point of this situation is that the lower-level functions don't know
there's anything wrong, pqReadData itself must set up the message.  But
keep the assumption that if an errno was reported, a message was set up at
lower levels.

Per bug #11712 from Marko Tiikkaja.  It's been like this for a very long
time, so back-patch to all supported branches.

9 years agoSmall code cleanup.
Michael Meskes [Wed, 22 Oct 2014 08:35:36 +0000 (10:35 +0200)]
Small code cleanup.

Declare static variable as static and external as extern.

9 years agoUpdate comment.
Heikki Linnakangas [Wed, 22 Oct 2014 12:39:28 +0000 (15:39 +0300)]
Update comment.

The _bt_tuplecompare() function mentioned in comment hasn't existed for a
long time.

Peter Geoghegan

9 years agoMinGW: Use -static-libgcc when linking a DLL.
Noah Misch [Wed, 22 Oct 2014 02:55:47 +0000 (22:55 -0400)]
MinGW: Use -static-libgcc when linking a DLL.

When commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027 switched the linker
driver from dlltool/dllwrap to gcc, it became possible for linking to
choose shared libgcc.  Backends having loaded a module dynamically
linked to libgcc can exit abnormally, which the postmaster treats like a
crash.  Resume use of static libgcc exclusively, like 9.3 and earlier.
Back-patch to 9.4.

9 years agoMinGW: Link with shell32.dll instead of shfolder.dll.
Noah Misch [Wed, 22 Oct 2014 02:55:43 +0000 (22:55 -0400)]
MinGW: Link with shell32.dll instead of shfolder.dll.

This improves consistency with the MSVC build.  On buildfarm member
narwhal, since commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027,
shfolder.dll:SHGetFolderPath() crashes when dblink calls it by way of
pqGetHomeDirectory().  Back-patch to 9.4, where that commit first
appeared.  How it caused this regression remains a mystery.  This is a
partial revert of commit 889f03812916b146ae504c0fad5afdc7bf2e8a2a, which
adopted shfolder.dll for Windows NT 4.0 compatibility.  PostgreSQL 8.2
dropped support for that operating system.

9 years agoUpdate expected/sequence_1.out.
Tom Lane [Tue, 21 Oct 2014 22:25:58 +0000 (18:25 -0400)]
Update expected/sequence_1.out.

The last three updates to the sequence regression test have all forgotten
to touch the alternate expected-output file.  Sigh.

Michael Paquier

9 years agoAllow input format xxxx-xxxx-xxxx for macaddr type
Peter Eisentraut [Tue, 21 Oct 2014 20:16:39 +0000 (16:16 -0400)]
Allow input format xxxx-xxxx-xxxx for macaddr type

Author: Herwin Weststrate <herwin@quarantainenet.nl>
Reviewed-by: Ali Akbar <the.apaan@gmail.com>
9 years agodoc: Check DocBook XML validity during the build
Peter Eisentraut [Tue, 21 Oct 2014 18:46:38 +0000 (14:46 -0400)]
doc: Check DocBook XML validity during the build

Building the documentation with XSLT does not check the DTD, like a
DSSSL build would.  One can often get away with having invalid XML, but
the stylesheets might then create incorrect output, as they are not
designed to handle that.  Therefore, check the validity of the XML
against the DTD, using xmllint, during the build.

Add xmllint detection to configure, and add some documentation.

xmllint comes with libxml2, which is already in use, but it might be in
a separate package, such as libxml2-utils on Debian.

Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>
9 years agodoc: Update Red Hat documentation tools information
Peter Eisentraut [Tue, 21 Oct 2014 14:43:09 +0000 (10:43 -0400)]
doc: Update Red Hat documentation tools information

The old text was written in ancient times when RPM packages could be
shared more or less freely across a plethora of RPM-based Linux
distributions.  This isn't really the case anymore, so just make this
information more concrete for the Red Hat family.

9 years agodoc: Update FreeBSD documentation tools information
Peter Eisentraut [Tue, 21 Oct 2014 14:32:28 +0000 (10:32 -0400)]
doc: Update FreeBSD documentation tools information

based on patch from Dag-Erling Smørgrav <des@des.no>

9 years agoDon't duplicate log_checkpoint messages for both of restart and checkpoints.
Andres Freund [Mon, 20 Oct 2014 23:01:56 +0000 (01:01 +0200)]
Don't duplicate log_checkpoint messages for both of restart and checkpoints.

The duplication originated in cdd46c765, where restartpoints were
introduced.

In LogCheckpointStart's case the duplication actually lead to the
compiler's format string checking not to be effective because the
format string wasn't constant.

Arguably these messages shouldn't be elog(), but ereport() style
messages. That'd even allow to translate the messages... But as
there's more mistakes of that kind in surrounding code, it seems
better to change that separately.

9 years agoRenumber CHECKPOINT_* flags.
Andres Freund [Mon, 20 Oct 2014 22:20:08 +0000 (00:20 +0200)]
Renumber CHECKPOINT_* flags.

Commit 7dbb6069382 added a new CHECKPOINT_FLUSH_ALL flag. As that
commit needed to be backpatched I didn't change the numeric values of
the existing flags as that could lead to nastly problems if any
external code issued checkpoints. That's not a concern on master, so
renumber them there.

Also add a comment about CHECKPOINT_FLUSH_ALL above
CreateCheckPoint().

9 years agoFlush unlogged table's buffers when copying or moving databases.
Andres Freund [Mon, 20 Oct 2014 21:43:46 +0000 (23:43 +0200)]
Flush unlogged table's buffers when copying or moving databases.

CREATE DATABASE and ALTER DATABASE .. SET TABLESPACE copy the source
database directory on the filesystem level. To ensure the on disk
state is consistent they block out users of the affected database and
force a checkpoint to flush out all data to disk. Unfortunately, up to
now, that checkpoint didn't flush out dirty buffers from unlogged
relations.

That bug means there could be leftover dirty buffers in either the
template database, or the database in its old location. Leading to
problems when accessing relations in an inconsistent state; and to
possible problems during shutdown in the SET TABLESPACE case because
buffers belonging files that don't exist anymore are flushed.

This was reported in bug #10675 by Maxim Boguk.

Fix by Pavan Deolasee, modified somewhat by me. Reviewed by MauMau and
Fujii Masao.

Backpatch to 9.1 where unlogged tables were introduced.

9 years agopg_test_fsync: Update output format
Peter Eisentraut [Mon, 20 Oct 2014 19:34:59 +0000 (15:34 -0400)]
pg_test_fsync: Update output format

Apparently, computers are now a bit faster than when this was first
added, so we need to make room for a digit or two in the ops/sec format.

While we're at it, adjust some of the other output for a more consistent
line length.

9 years agoCorrect volatility markings of a few json functions.
Andrew Dunstan [Mon, 20 Oct 2014 18:55:35 +0000 (14:55 -0400)]
Correct volatility markings of a few json functions.

json_agg and json_object_agg and their associated transition functions
should have been marked as stable rather than immutable, as they call IO
functions indirectly. Changing this probably isn't going to make much
difference, as you can't use an aggregate function in an index
expression, but we should be correct nevertheless.

json_object, on the other hand, should be marked immutable rather than
stable, as it does not call IO functions.

As discussed on -hackers, this change is being made without bumping the
catalog version, as we don't want to do that at this stage of the  cycle,
and  the changes are very unlikely to affect anyone.

9 years agoFix mishandling of FieldSelect-on-whole-row-Var in nested lateral queries.
Tom Lane [Mon, 20 Oct 2014 16:23:42 +0000 (12:23 -0400)]
Fix mishandling of FieldSelect-on-whole-row-Var in nested lateral queries.

If an inline-able SQL function taking a composite argument is used in a
LATERAL subselect, and the composite argument is a lateral reference,
the planner could fail with "variable not found in subplan target list",
as seen in bug #11703 from Karl Bartel.  (The outer function call used in
the bug report and in the committed regression test is not really necessary
to provoke the bug --- you can get it if you manually expand the outer
function into "LATERAL (SELECT inner_function(outer_relation))", too.)

The cause of this is that we generate the reltargetlist for the referenced
relation before doing eval_const_expressions() on the lateral sub-select's
expressions (cf find_lateral_references()), so what's scheduled to be
emitted by the referenced relation is a whole-row Var, not the simplified
single-column Var produced by optimizing the function's FieldSelect on the
whole-row Var.  Then setrefs.c fails to match up that lateral reference to
what's available from the outer scan.

Preserving the FieldSelect optimization in such cases would require either
major planner restructuring (to recursively do expression simplification
on sub-selects much earlier) or some amazingly ugly kluge to change the
reltargetlist of a possibly-already-planned relation.  It seems better
just to skip the optimization when the Var is from an upper query level;
the case is not so common that it's likely anyone will notice a few
wasted cycles.

AFAICT this problem only occurs for uplevel LATERAL references, so
back-patch to 9.3 where LATERAL was added.

9 years agoFix file-identification comment in contrib/pgcrypto/pgcrypto--1.2.sql.
Tom Lane [Mon, 20 Oct 2014 14:53:57 +0000 (10:53 -0400)]
Fix file-identification comment in contrib/pgcrypto/pgcrypto--1.2.sql.

Cosmetic oversight in commit 32984d8fc3dbb90a3fafb69fece0134f1ea790f9.

Marko Tiikkaja

9 years agoFix typos.
Robert Haas [Mon, 20 Oct 2014 14:33:16 +0000 (10:33 -0400)]
Fix typos.

David Rowley

9 years agoFix typos.
Robert Haas [Mon, 20 Oct 2014 14:23:40 +0000 (10:23 -0400)]
Fix typos.

Etsuro Fujita

9 years agoinitdb: Fix compiler error in USE_PREFETCH case
Peter Eisentraut [Sun, 19 Oct 2014 04:45:40 +0000 (00:45 -0400)]
initdb: Fix compiler error in USE_PREFETCH case

9 years agopsql: Improve \pset without arguments
Peter Eisentraut [Sun, 19 Oct 2014 01:58:17 +0000 (21:58 -0400)]
psql: Improve \pset without arguments

Revert the output of the individual backslash commands that change print
settings back to the 9.3 way (not showing the command name in
parentheses).  Implement \pset without arguments separately, showing all
settings with values in a table form.

9 years agoAllow setting effective_io_concurrency even on unsupported systems
Peter Eisentraut [Sun, 19 Oct 2014 01:35:46 +0000 (21:35 -0400)]
Allow setting effective_io_concurrency even on unsupported systems

This matches the behavior of other parameters that are unsupported on
some systems (e.g., ssl).

Also document the default value.

9 years agoShorten warning about hash creation
Bruce Momjian [Sat, 18 Oct 2014 14:36:09 +0000 (10:36 -0400)]
Shorten warning about hash creation

Also document that PITR is also affected.

9 years agointerval: tighten precision specification
Bruce Momjian [Sat, 18 Oct 2014 14:31:00 +0000 (10:31 -0400)]
interval:  tighten precision specification

interval precision can only be specified after the "interval" keyword if
no units are specified.

Previously we incorrectly checked the units to see if the precision was
legal, causing confusion.

Report by Alvaro Herrera

9 years agodoc: restrictions on alter database moving default tablespace
Bruce Momjian [Sat, 18 Oct 2014 14:23:42 +0000 (10:23 -0400)]
doc:  restrictions on alter database moving default tablespace

Mention tablespace must be empty and no one connected to the database.

Report by Josh Berkus

9 years agodoc: Clean up pg_recvlogical reference page
Peter Eisentraut [Sat, 18 Oct 2014 13:10:12 +0000 (09:10 -0400)]
doc: Clean up pg_recvlogical reference page

This needed a general cleanup of wording, typos, outdated terminology,
formatting, and hard-to-understand and borderline incorrect information.

Also tweak the pg_receivexlog page a bit to make the two more
consistent.

9 years agoDeclare mkdtemp() only if we're providing it.
Tom Lane [Sat, 18 Oct 2014 02:55:20 +0000 (22:55 -0400)]
Declare mkdtemp() only if we're providing it.

Follow our usual style of providing an "extern" for a standard library
function only when we're also providing the implementation.  This avoids
issues when the system headers declare the function slightly differently
than we do, as noted by Caleb Welton.

We might have to go to the extent of probing to see if the system headers
declare the function, but let's not do that until it's demonstrated to be
necessary.

Oversight in commit 9e6b1bf258170e62dac555fc82ff0536dfe01d29.  Back-patch
to all supported branches, as that was.

9 years agoAvoid core dump in _outPathInfo() for Path without a parent RelOptInfo.
Tom Lane [Sat, 18 Oct 2014 02:32:55 +0000 (22:32 -0400)]
Avoid core dump in _outPathInfo() for Path without a parent RelOptInfo.

Nearly all Paths have parents, but a ResultPath representing an empty FROM
clause does not.  Avoid a core dump in such cases.  I believe this is only
a hazard for debugging usage, not for production, else we'd have heard
about it before.  Nonetheless, back-patch to 9.1 where the troublesome code
was introduced.  Noted while poking at bug #11703.

9 years agoFix bug in handling of connections that pg_receivexlog creates.
Fujii Masao [Fri, 17 Oct 2014 18:06:34 +0000 (03:06 +0900)]
Fix bug in handling of connections that pg_receivexlog creates.

Previously pg_receivexlog created new connection for WAL streaming
even though another connection which had been established to create
or delete the replication slot was being left. This caused the unused
connection to be left uselessly until pg_receivexlog exited.
This bug was introduced by the commit d9f38c7.

This patch changes pg_receivexlog so that the connection for
the replication slot is reused for WAL streaming.

Andres Freund, slightly modified by me, reviewed by Michael Paquier

9 years agoFix core dump in pg_dump --binary-upgrade on zero-column composite type.
Tom Lane [Fri, 17 Oct 2014 16:49:00 +0000 (12:49 -0400)]
Fix core dump in pg_dump --binary-upgrade on zero-column composite type.

This reverts nearly all of commit 28f6cab61ab8958b1a7dfb019724687d92722538
in favor of just using the typrelid we already have in pg_dump's TypeInfo
struct for the composite type.  As coded, it'd crash if the composite type
had no attributes, since then the query would return no rows.

Back-patch to all supported versions.  It seems to not really be a problem
in 9.0 because that version rejects the syntax "create type t as ()", but
we might as well keep the logic similar in all affected branches.

Report and fix by Rushabh Lathia.

9 years agoRe-pgindent src/bin/pg_dump/*.
Tom Lane [Fri, 17 Oct 2014 16:19:05 +0000 (12:19 -0400)]
Re-pgindent src/bin/pg_dump/*.

Seems to have gotten rather messy lately, as a consequence of a couple
of large recent commits.

9 years agoFix pg_dump for UPDATE policies
Stephen Frost [Fri, 17 Oct 2014 12:07:46 +0000 (08:07 -0400)]
Fix pg_dump for UPDATE policies

pg_dump had the wrong character for update and so was failing when
attempts were made to pg_dump databases with UPDATE policies.

Pointed out by Fujii Masao (thanks!)

9 years agoSupport timezone abbreviations that sometimes change.
Tom Lane [Thu, 16 Oct 2014 19:22:10 +0000 (15:22 -0400)]
Support timezone abbreviations that sometimes change.

Up to now, PG has assumed that any given timezone abbreviation (such as
"EDT") represents a constant GMT offset in the usage of any particular
region; we had a way to configure what that offset was, but not for it
to be changeable over time.  But, as with most things horological, this
view of the world is too simplistic: there are numerous regions that have
at one time or another switched to a different GMT offset but kept using
the same timezone abbreviation.  Almost the entire Russian Federation did
that a few years ago, and later this month they're going to do it again.
And there are similar examples all over the world.

To cope with this, invent the notion of a "dynamic timezone abbreviation",
which is one that is referenced to a particular underlying timezone
(as defined in the IANA timezone database) and means whatever it currently
means in that zone.  For zones that use or have used daylight-savings time,
the standard and DST abbreviations continue to have the property that you
can specify standard or DST time and get that time offset whether or not
DST was theoretically in effect at the time.  However, the abbreviations
mean what they meant at the time in question (or most recently before that
time) rather than being absolutely fixed.

The standard abbreviation-list files have been changed to use this behavior
for abbreviations that have actually varied in meaning since 1970.  The
old simple-numeric definitions are kept for abbreviations that have not
changed, since they are a bit faster to resolve.

While this is clearly a new feature, it seems necessary to back-patch it
into all active branches, because otherwise use of Russian zone
abbreviations is going to become even more problematic than it already was.
This change supersedes the changes in commit 513d06ded et al to modify the
fixed meanings of the Russian abbreviations; since we've not shipped that
yet, this will avoid an undesirably incompatible (not to mention incorrect)
change in behavior for timestamps between 2011 and 2014.

This patch makes some cosmetic changes in ecpglib to keep its usage of
datetime lookup tables as similar as possible to the backend code, but
doesn't do anything about the increasingly obsolete set of timezone
abbreviation definitions that are hard-wired into ecpglib.  Whatever we
do about that will likely not be appropriate material for back-patching.
Also, a potential free() of a garbage pointer after an out-of-memory
failure in ecpglib has been fixed.

This patch also fixes pre-existing bugs in DetermineTimeZoneOffset() that
caused it to produce unexpected results near a timezone transition, if
both the "before" and "after" states are marked as standard time.  We'd
only ever thought about or tested transitions between standard and DST
time, but that's not what's happening when a zone simply redefines their
base GMT offset.

In passing, update the SGML documentation to refer to the Olson/zoneinfo/
zic timezone database as the "IANA" database, since it's now being
maintained under the auspices of IANA.

9 years agoPrint planning time only in EXPLAIN ANALYZE, not plain EXPLAIN.
Tom Lane [Wed, 15 Oct 2014 22:50:13 +0000 (18:50 -0400)]
Print planning time only in EXPLAIN ANALYZE, not plain EXPLAIN.

We've gotten enough push-back on that change to make it clear that it
wasn't an especially good idea to do it like that.  Revert plain EXPLAIN
to its previous behavior, but keep the extra output in EXPLAIN ANALYZE.
Per discussion.

Internally, I set this up as a separate flag ExplainState.summary that
controls printing of planning time and execution time.  For now it's
just copied from the ANALYZE option, but we could consider exposing it
to users.

9 years agoBlind attempt at fixing Win32 pg_dump issues
Alvaro Herrera [Tue, 14 Oct 2014 20:33:36 +0000 (17:33 -0300)]
Blind attempt at fixing Win32 pg_dump issues

Per buildfarm failures

9 years agopg_dump: Reduce use of global variables
Alvaro Herrera [Tue, 14 Oct 2014 18:00:55 +0000 (15:00 -0300)]
pg_dump: Reduce use of global variables

Most pg_dump.c global variables, which were passed down individually to
dumping routines, are now grouped as members of the new DumpOptions
struct, which is used as a local variable and passed down into routines
that need it.  This helps future development efforts; in particular it
is said to enable a mode in which a parallel pg_dump run can output
multiple streams, and have them restored in parallel.

Also take the opportunity to clean up the pg_dump header files somewhat,
to avoid circularity.

Author: Joachim Wieland, revised by Álvaro Herrera
Reviewed by Peter Eisentraut

9 years agoFix deadlock with LWLockAcquireWithVar and LWLockWaitForVar.
Heikki Linnakangas [Tue, 14 Oct 2014 06:55:26 +0000 (09:55 +0300)]
Fix deadlock with LWLockAcquireWithVar and LWLockWaitForVar.

LWLockRelease should release all backends waiting with LWLockWaitForVar,
even when another backend has already been woken up to acquire the lock,
i.e. when releaseOK is false. LWLockWaitForVar can return as soon as the
protected value changes, even if the other backend will acquire the lock.
Fix that by resetting releaseOK to true in LWLockWaitForVar, whenever
adding itself to the wait queue.

This should fix the bug reported by MauMau, where the system occasionally
hangs when there is a lot of concurrent WAL activity and a checkpoint.
Backpatch to 9.4, where this code was added.

9 years agoFix typo in docs.
Heikki Linnakangas [Tue, 14 Oct 2014 06:45:00 +0000 (09:45 +0300)]
Fix typo in docs.

Shigeru Hanada

9 years agodoc: Improve ALTER VIEW / SET documentation
Peter Eisentraut [Tue, 14 Oct 2014 02:17:34 +0000 (22:17 -0400)]
doc: Improve ALTER VIEW / SET documentation

The way the ALTER VIEW / SET options were listed in the synopsis was
very confusing.  Move the list to the main description, similar to how
the ALTER TABLE reference page does it.

9 years agodoc: Fix copy-and-paste mistakes
Peter Eisentraut [Tue, 14 Oct 2014 02:10:01 +0000 (22:10 -0400)]
doc: Fix copy-and-paste mistakes

9 years agopsql: Fix \? output alignment
Peter Eisentraut [Tue, 14 Oct 2014 02:07:30 +0000 (22:07 -0400)]
psql: Fix \? output alignment

This was inadvertently changed in commit c64e68fd.

9 years agodoc: mention TM is ignored for to_date/to_timestamp()
Bruce Momjian [Mon, 13 Oct 2014 21:36:50 +0000 (17:36 -0400)]
doc:  mention TM is ignored for to_date/to_timestamp()

Report by Goulven Guillard

9 years agodoc: mention more changes needed to use huge pages
Bruce Momjian [Mon, 13 Oct 2014 21:23:36 +0000 (17:23 -0400)]
doc:  mention more changes needed to use huge pages

Report by Laurence Parry

9 years agoC comments: adjust execTuples.c for new structure
Bruce Momjian [Mon, 13 Oct 2014 20:54:38 +0000 (16:54 -0400)]
C comments: adjust execTuples.c for new structure

Report by Peter Geoghegan

9 years agodocs: error for adding _validated_ domains for existing uses
Bruce Momjian [Mon, 13 Oct 2014 20:44:20 +0000 (16:44 -0400)]
docs: error for adding  _validated_ domains for existing uses

Report by David G Johnston

9 years agoConsistently use NULL for invalid GUC unit strings
Bruce Momjian [Mon, 13 Oct 2014 20:11:43 +0000 (16:11 -0400)]
Consistently use NULL for invalid GUC unit strings

Patch by Euler Taveira

9 years agodoc: improve USING and NATURAL JOIN descriptions
Bruce Momjian [Mon, 13 Oct 2014 19:39:49 +0000 (15:39 -0400)]
doc: improve USING and NATURAL JOIN descriptions

Patch by David G Johnston

9 years agoAdd --latency-limit option to pgbench.
Heikki Linnakangas [Mon, 13 Oct 2014 17:25:56 +0000 (20:25 +0300)]
Add --latency-limit option to pgbench.

This allows transactions that take longer than specified limit to be counted
separately. With --rate, transactions that are already late by the time we
get to execute them are skipped altogether. Using --latency-limit with
--rate allows you to "catch up" more quickly, if there's a hickup in the
server causing a lot of transactions to stall momentarily.

Fabien COELHO, reviewed by Rukh Meski and heavily refactored by me.

9 years agoIncrease number of hash join buckets for underestimate.
Kevin Grittner [Mon, 13 Oct 2014 15:16:36 +0000 (10:16 -0500)]
Increase number of hash join buckets for underestimate.

If we expect batching at the very beginning, we size nbuckets for
"full work_mem" (see how many tuples we can get into work_mem,
while not breaking NTUP_PER_BUCKET threshold).

If we expect to be fine without batching, we start with the 'right'
nbuckets and track the optimal nbuckets as we go (without actually
resizing the hash table). Once we hit work_mem (considering the
optimal nbuckets value), we keep the value.

At the end of the first batch, we check whether (nbuckets !=
nbuckets_optimal) and resize the hash table if needed. Also, we
keep this value for all batches (it's OK because it assumes full
work_mem, and it makes the batchno evaluation trivial). So the
resize happens only once.

There could be cases where it would improve performance to allow
the NTUP_PER_BUCKET threshold to be exceeded to keep everything in
one batch rather than spilling to a second batch, but attempts to
generate such a case have so far been unsuccessful; that issue may
be addressed with a follow-on patch after further investigation.

Tomas Vondra with minor format and comment cleanup by me
Reviewed by Robert Haas, Heikki Linnakangas, and Kevin Grittner

9 years agoFix quoting in the add_to_path Makefile macro.
Noah Misch [Mon, 13 Oct 2014 03:33:37 +0000 (23:33 -0400)]
Fix quoting in the add_to_path Makefile macro.

The previous quoting caused "make -C src/bin check" to ignore, rather
than add to, any LD_LIBRARY_PATH content from the environment.
Back-patch to 9.4, where the macro was introduced.

9 years agopg_ctl: Cast DWORD values to avoid -Wformat warnings.
Noah Misch [Mon, 13 Oct 2014 03:33:19 +0000 (23:33 -0400)]
pg_ctl: Cast DWORD values to avoid -Wformat warnings.

This affects pg_ctl alone, because pg_ctl takes the exceptional step of
calling Windows API functions in a Cygwin build.

9 years agoSuppress dead, unportable src/port/crypt.c code.
Noah Misch [Mon, 13 Oct 2014 03:27:06 +0000 (23:27 -0400)]
Suppress dead, unportable src/port/crypt.c code.

This file used __int64, which is specific to native Windows, rather than
int64.  Suppress the long-unused union field of this type.  Noticed on
Cygwin x86_64 with -lcrypt not installed.  Back-patch to 9.0 (all
supported versions).

9 years agopg_recvlogical: Improve --help output
Peter Eisentraut [Sun, 12 Oct 2014 05:45:25 +0000 (01:45 -0400)]
pg_recvlogical: Improve --help output

List the actions first, as they are the most important options.  Group
the other options more sensibly, consistent with the man page.  Correct
a few typographical errors, clarify some things.

Also update the pg_receivexlog --help output to make it a bit more
consistent with that of pg_recvlogical.

9 years agoMessage improvements
Peter Eisentraut [Sun, 12 Oct 2014 05:02:56 +0000 (01:02 -0400)]
Message improvements

9 years agopg_upgrade: prefix Unix shell script name output with "./"
Bruce Momjian [Sat, 11 Oct 2014 22:38:41 +0000 (18:38 -0400)]
pg_upgrade:  prefix Unix shell script name output with "./"

This more clearly suggests the current directory.  While this also works
on Windows, it might be confusing.

Report by Christoph Berg

9 years agodocs: remove mention that attnotnull should be changed
Bruce Momjian [Sat, 11 Oct 2014 21:23:57 +0000 (17:23 -0400)]
docs:  remove mention that attnotnull should be changed

Report by Andres Freund

9 years agoregression: adjust polygon diagrams to not use tabs
Bruce Momjian [Sat, 11 Oct 2014 21:14:16 +0000 (17:14 -0400)]
regression:  adjust polygon diagrams to not use tabs

Also, small diagram adjustments

Patch by Emre Hasegeli

9 years agoImprove documentation about JSONB array containment behavior.
Tom Lane [Sat, 11 Oct 2014 18:29:51 +0000 (14:29 -0400)]
Improve documentation about JSONB array containment behavior.

Per gripe from Josh Berkus.

9 years agoFix bogus optimization in JSONB containment tests.
Tom Lane [Sat, 11 Oct 2014 18:13:51 +0000 (14:13 -0400)]
Fix bogus optimization in JSONB containment tests.

When determining whether one JSONB object contains another, it's okay to
make a quick exit if the first object has fewer pairs than the second:
because we de-duplicate keys within objects, it is impossible that the
first object has all the keys the second does.  However, the code was
applying this rule to JSONB arrays as well, where it does *not* hold
because arrays can contain duplicate entries.  The test was really in
the wrong place anyway; we should do it within JsonbDeepContains, where
it can be applied to nested objects not only top-level ones.

Report and test cases by Alexander Korotkov; fix by Peter Geoghegan and
Tom Lane.

9 years agoRemove unnecessary initialization of local variables.
Heikki Linnakangas [Fri, 10 Oct 2014 10:00:53 +0000 (13:00 +0300)]
Remove unnecessary initialization of local variables.

Oops, forgot these in the prveious commit.

9 years agoChange the way encoding and locale checks are done in pg_upgrade.
Heikki Linnakangas [Fri, 10 Oct 2014 06:59:44 +0000 (09:59 +0300)]
Change the way encoding and locale checks are done in pg_upgrade.

Lc_collate and lc_ctype have been per-database settings since server version
8.4, but pg_upgrade was still treating them as cluster-wide options. It
fetched the values for the template0 databases in old and new cluster, and
compared them. That's backwards; the encoding and locale of the template0
database doesn't matter, as template0 is guaranteed to contain only ASCII
characters. But if there are any other databases that exist on both clusters
(in particular template1 and postgres databases), their encodings and
locales must be compatible.

Also, make the locale comparison more lenient. If the locale names are not
equal, try to canonicalize both of them by passing them to setlocale(). We
used to do that only when upgrading from 9.1 or below, but it seems like a
good idea even with newer versions. If we change the canonical form of a
locale, this allows pg_upgrade to still work. I'm about to do just that to
fix bug #11431, by mapping a locale name that contains non-ASCII characters
to a pure-ASCII alias of the same locale.

No backpatching, because earlier versions of pg_upgrade still support
upgrading from 8.3 servers. That would be more complicated, so it doesn't
seem worth it, given that we haven't received any complaints about this
from users.

9 years agoFix broken example in PL/pgSQL document.
Fujii Masao [Thu, 9 Oct 2014 18:18:01 +0000 (03:18 +0900)]
Fix broken example in PL/pgSQL document.

Back-patch to all supported branches.

Marti Raudsepp, per a report from Marko Tiikkaja

9 years agoSplit builtins.h to a new header ruleutils.h
Alvaro Herrera [Wed, 8 Oct 2014 21:10:47 +0000 (18:10 -0300)]
Split builtins.h to a new header ruleutils.h

The new header contains many prototypes for functions in ruleutils.c
that are not exposed to the SQL level.

Reviewed by Andres Freund and Michael Paquier.

9 years agoExtend shm_mq API with new functions shm_mq_sendv, shm_mq_set_handle.
Robert Haas [Wed, 8 Oct 2014 18:35:43 +0000 (14:35 -0400)]
Extend shm_mq API with new functions shm_mq_sendv, shm_mq_set_handle.

shm_mq_sendv sends a message to the queue assembled from multiple
locations.  This is expected to be used by forthcoming patches to
allow frontend/backend protocol messages to be sent via shm_mq, but
might be useful for other purposes as well.

shm_mq_set_handle associates a BackgroundWorkerHandle with an
already-existing shm_mq_handle.  This solves a timing problem when
creating a shm_mq to communicate with a newly-launched background
worker: if you attach to the queue first, and the background worker
fails to start, you might block forever trying to do I/O on the queue;
but if you start the background worker first, but then die before
attaching to the queue, the background worrker might block forever
trying to do I/O on the queue.  This lets you attach before starting
the worker (so that the worker is protected) and then associate the
BackgroundWorkerHandle later (so that you are also protected).

Patch by me, reviewed by Stephen Frost.

9 years agoImplement SKIP LOCKED for row-level locks
Alvaro Herrera [Tue, 7 Oct 2014 20:23:34 +0000 (17:23 -0300)]
Implement SKIP LOCKED for row-level locks

This clause changes the behavior of SELECT locking clauses in the
presence of locked rows: instead of causing a process to block waiting
for the locks held by other processes (or raise an error, with NOWAIT),
SKIP LOCKED makes the new reader skip over such rows.  While this is not
appropriate behavior for general purposes, there are some cases in which
it is useful, such as queue-like tables.

Catalog version bumped because this patch changes the representation of
stored rules.

Reviewed by Craig Ringer (based on a previous attempt at an
implementation by Simon Riggs, who also provided input on the syntax
used in the current patch), David Rowley, and Álvaro Herrera.

Author: Thomas Munro

9 years agoFix typo in elog message.
Robert Haas [Tue, 7 Oct 2014 04:08:59 +0000 (00:08 -0400)]
Fix typo in elog message.

9 years agoFix array overrun in ecpg's version of ParseDateTime().
Tom Lane [Tue, 7 Oct 2014 01:23:20 +0000 (21:23 -0400)]
Fix array overrun in ecpg's version of ParseDateTime().

The code wrote a value into the caller's field[] array before checking
to see if there was room, which of course is backwards.  Per report from
Michael Paquier.

I fixed the equivalent bug in the backend's version of this code way back
in 630684d3a130bb93, but failed to think about ecpg's copy.  Fortunately
this doesn't look like it would be exploitable for anything worse than a
core dump: an external attacker would have no control over the single word
that gets written.

9 years agoClean up Create/DropReplicationSlot query buffer
Stephen Frost [Mon, 6 Oct 2014 15:18:13 +0000 (11:18 -0400)]
Clean up Create/DropReplicationSlot query buffer

CreateReplicationSlot() and DropReplicationSlot() were not cleaning up
the query buffer in some cases (mostly error conditions) which meant a
small leak.  Not generally an issue as the error case would result in an
immediate exit, but not difficult to fix either and reduces the number
of false positives from code analyzers.

In passing, also add appropriate PQclear() calls to RunIdentifySystem().

Pointed out by Coverity.

9 years agoAdd support for managing physical replication slots to pg_receivexlog.
Andres Freund [Mon, 6 Oct 2014 10:51:37 +0000 (12:51 +0200)]
Add support for managing physical replication slots to pg_receivexlog.

pg_receivexlog already has the capability to use a replication slot to
reserve WAL on the upstream node. But the used slot currently has to
be created via SQL.

To allow using slots directly, without involving SQL, add
--create-slot and --drop-slot actions, analogous to the logical slot
manipulation support in pg_recvlogical.

Author: Michael Paquier
Discussion: CABUevEx+zrOHZOQg+dPapNPFRJdsk59b=TSVf30Z71GnFXhQaw@mail.gmail.com

9 years agoRename pg_recvlogical's --create/--drop to --create-slot/--drop-slot.
Andres Freund [Mon, 6 Oct 2014 10:11:52 +0000 (12:11 +0200)]
Rename pg_recvlogical's --create/--drop to --create-slot/--drop-slot.

A future patch (9.5 only) adds slot management to pg_receivexlog. The
verbs create/drop don't seem descriptive enough there. It seems better
to rename pg_recvlogical's commands now, in beta, than live with the
inconsistency forever.

The old form (e.g. --drop) will still be accepted by virtue of most
getopt_long() options accepting abbreviations for long commands.

Backpatch to 9.4 where pg_recvlogical was introduced.

Author: Michael Paquier and Andres Freund
Discussion: CAB7nPqQtt79U6FmhwvgqJmNyWcVCbbV-nS72j_jyPEopERg9rg@mail.gmail.com

9 years agoTranslation updates
Peter Eisentraut [Mon, 6 Oct 2014 03:22:24 +0000 (23:22 -0400)]
Translation updates

9 years agoUpdate 9.4 release notes for commits through today.
Tom Lane [Sun, 5 Oct 2014 18:14:04 +0000 (14:14 -0400)]
Update 9.4 release notes for commits through today.

Add entries for recent changes, including noting the JSONB format change
and the recent timezone data changes.  We should remove those two items
before 9.4 final: the JSONB change will be of no interest in the long
run, and it's not normally our habit to mention timezone updates in
major-release notes.  But it seems important to document them temporarily
for beta testers.

I failed to resist the temptation to wordsmith a couple of existing
entries, too.

9 years agoEliminate one background-worker-related flag variable.
Robert Haas [Sun, 5 Oct 2014 01:25:41 +0000 (21:25 -0400)]
Eliminate one background-worker-related flag variable.

Teach sigusr1_handler() to use the same test for whether a worker
might need to be started as ServerLoop().  Aside from being perhaps
a bit simpler, this prevents a potentially-unbounded delay when
starting a background worker.  On some platforms, select() doesn't
return when interrupted by a signal, but is instead restarted,
including a reset of the timeout to the originally-requested value.
If signals arrive often enough, but no connection requests arrive,
sigusr1_handler() will be executed repeatedly, but the body of
ServerLoop() won't be reached.  This change ensures that, even in
that case, background workers will eventually get launched.

This is far from a perfect fix; really, we need select() to return
control to ServerLoop() after an interrupt, either via the self-pipe
trick or some other mechanism.  But that's going to require more
work and discussion, so let's do this for now to at least mitigate
the damage.

Per investigation of test_shm_mq failures on buildfarm member anole.

9 years agoUpdate time zone data files to tzdata release 2014h.
Tom Lane [Sat, 4 Oct 2014 18:18:19 +0000 (14:18 -0400)]
Update time zone data files to tzdata release 2014h.

Most zones in the Russian Federation are subtracting one or two hours
as of 2014-10-26.  Update the meanings of the abbreviations IRKT, KRAT,
MAGT, MSK, NOVT, OMST, SAKT, VLAT, YAKT, YEKT to match.

The IANA timezone database has adopted abbreviations of the form AxST/AxDT
for all Australian time zones, reflecting what they believe to be current
majority practice Down Under.  These names do not conflict with usage
elsewhere (other than ACST for Acre Summer Time, which has been in disuse
since 1994).  Accordingly, adopt these names into our "Default" timezone
abbreviation set.  The "Australia" abbreviation set now contains only
CST,EAST,EST,SAST,SAT,WST, all of which are thought to be mostly historical
usage.  Note that SAST has also been changed to be South Africa Standard
Time in the "Default" abbreviation set.

Add zone abbreviations SRET (Asia/Srednekolymsk) and XJT (Asia/Urumqi),
and use WSST/WSDT for western Samoa.

Also a DST law change in the Turks & Caicos Islands (America/Grand_Turk),
and numerous corrections for historical time zone data.

9 years agoUpdate time zone abbreviations lists.
Tom Lane [Fri, 3 Oct 2014 21:44:38 +0000 (17:44 -0400)]
Update time zone abbreviations lists.

This updates known_abbrevs.txt to be what it should have been already,
were my -P patch not broken; and updates some tznames/ entries that
missed getting any love in previous timezone data updates because zic
failed to flag the change of abbreviation.

The non-cosmetic updates:

* Remove references to "ADT" as "Arabia Daylight Time", an abbreviation
that's been out of use since 2007; therefore, claiming there is a conflict
with "Atlantic Daylight Time" doesn't seem especially helpful.  (We have
left obsolete entries in the files when they didn't conflict with anything,
but that seems like a different situation.)

* Fix entirely incorrect GMT offsets for CKT (Cook Islands), FJT, FJST
(Fiji); we didn't even have them on the proper side of the date line.
(Seems to have been aboriginal errors in our tznames data; there's no
evidence anything actually changed recently.)

* FKST (Falkland Islands Summer Time) is now used all year round, so
don't mark it as a DST abbreviation.

* Update SAKT (Sakhalin) to mean GMT+11 not GMT+10.

In cosmetic changes, I fixed a bunch of wrong (or at least obsolete)
claims about abbreviations not being present in the zic files, and
tried to be consistent about how obsolete abbreviations are labeled.

Note the underlying timezone/data files are still at release 2014e;
this is just trying to get us in sync with what those files actually
say before we go to the next update.

9 years agoFix CreatePolicy, pg_dump -v; psql and doc updates
Stephen Frost [Fri, 3 Oct 2014 20:31:53 +0000 (16:31 -0400)]
Fix CreatePolicy, pg_dump -v; psql and doc updates

Peter G pointed out that valgrind was, rightfully, complaining about
CreatePolicy() ending up copying beyond the end of the parsed policy
name.  Name is a fixed-size type and we need to use namein (through
DirectFunctionCall1()) to flush out the entire array before we pass
it down to heap_form_tuple.

Michael Paquier pointed out that pg_dump --verbose was missing a
newline and Fabrízio de Royes Mello further pointed out that the
schema was also missing from the messages, so fix those also.

Also, based on an off-list comment from Kevin, rework the psql \d
output to facilitate copy/pasting into a new CREATE or ALTER POLICY
command.

Lastly, improve the pg_policies view and update the documentation for
it, along with a few other minor doc corrections based on an off-list
discussion with Adam Brightwell.

9 years agoFix bogus logic for zic -P option.
Tom Lane [Fri, 3 Oct 2014 18:48:11 +0000 (14:48 -0400)]
Fix bogus logic for zic -P option.

The quick hack I added to zic to dump out currently-in-use timezone
abbreviations turns out to have a nasty bug: within each zone, it was
printing the last "struct ttinfo" to be *defined*, not necessarily the
last one in use.  This was mainly a problem in zones that had changed the
meaning of their zone abbreviation (to another GMT offset value) and later
changed it back.

As a result of this error, we'd missed out updating the tznames/ files
for some jurisdictions that have changed their zone abbreviations since
the tznames/ files were originally created.  I'll address the missing data
updates in a separate commit.

9 years agoDon't balance vacuum cost delay when per-table settings are in effect
Alvaro Herrera [Fri, 3 Oct 2014 16:01:27 +0000 (13:01 -0300)]
Don't balance vacuum cost delay when per-table settings are in effect

When there are cost-delay-related storage options set for a table,
trying to make that table participate in the autovacuum cost-limit
balancing algorithm produces undesirable results: instead of using the
configured values, the global values are always used,
as illustrated by Mark Kirkwood in
http://www.postgresql.org/message-id/52FACF15.8020507@catalyst.net.nz

Since the mechanism is already complicated, just disable it for those
cases rather than trying to make it cope.  There are undesirable
side-effects from this too, namely that the total I/O impact on the
system will be higher whenever such tables are vacuumed.  However, this
is seen as less harmful than slowing down vacuum, because that would
cause bloat to accumulate.  Anyway, in the new system it is possible to
tweak options to get the precise behavior one wants, whereas with the
previous system one was simply hosed.

This has been broken forever, so backpatch to all supported branches.
This might affect systems where cost_limit and cost_delay have been set
for individual tables.

9 years agoFix typos in comments.
Robert Haas [Fri, 3 Oct 2014 15:47:27 +0000 (11:47 -0400)]
Fix typos in comments.

Etsuro Fujita

9 years agoStill another typo fix for 0709b7ee72e4bc71ad07b7120acd117265ab51d0.
Robert Haas [Fri, 3 Oct 2014 15:25:28 +0000 (11:25 -0400)]
Still another typo fix for 0709b7ee72e4bc71ad07b7120acd117265ab51d0.

Buildfarm member anole caught this one.

9 years agoCheck for GiST index tuples that don't fit on a page.
Heikki Linnakangas [Fri, 3 Oct 2014 09:07:10 +0000 (12:07 +0300)]
Check for GiST index tuples that don't fit on a page.

The page splitting code would go into infinite recursion if you try to
insert an index tuple that doesn't fit even on an empty page.

Per analysis and suggested fix by Andrew Gierth. Fixes bug #11555, reported
by Bryan Seitz (analysis happened over IRC). Backpatch to all supported
versions.

9 years agoFix documentation for CREATE SEQUENCE IF NOT EXISTS.
Heikki Linnakangas [Fri, 3 Oct 2014 07:24:10 +0000 (10:24 +0300)]
Fix documentation for CREATE SEQUENCE IF NOT EXISTS.

The [ IF NOT EXISTS ] was put in wrong place in the syntax.

Pointed out by Marti Raudsepp.

9 years agoIncrease the number of buffer mapping partitions to 128.
Robert Haas [Thu, 2 Oct 2014 17:58:50 +0000 (13:58 -0400)]
Increase the number of buffer mapping partitions to 128.

Testing by Amit Kapila, Andres Freund, and myself, with and without
other patches that also aim to improve scalability, seems to indicate
that this change is a significant win over the current value and over
smaller values such as 64.  It's not clear how high we can push this
value before it starts to have negative side-effects elsewhere, but
going this far looks OK.

9 years agoInstall all headers for the new atomics API.
Andres Freund [Thu, 2 Oct 2014 14:39:36 +0000 (16:39 +0200)]
Install all headers for the new atomics API.

Previously, by mistake, only atomics.h was installed.

Kohei KaiGai

9 years agoFix typo in error message.
Heikki Linnakangas [Thu, 2 Oct 2014 12:51:31 +0000 (15:51 +0300)]
Fix typo in error message.

9 years agoRefactor pgbench log-writing code to a separate function.
Heikki Linnakangas [Thu, 2 Oct 2014 09:58:14 +0000 (12:58 +0300)]
Refactor pgbench log-writing code to a separate function.

The doCustom function was incredibly long, this makes it a little bit more
readable.

9 years agoFix some more problems with nested append relations.
Tom Lane [Wed, 1 Oct 2014 23:30:24 +0000 (19:30 -0400)]
Fix some more problems with nested append relations.

As of commit a87c72915 (which later got backpatched as far as 9.1),
we're explicitly supporting the notion that append relations can be
nested; this can occur when UNION ALL constructs are nested, or when
a UNION ALL contains a table with inheritance children.

Bug #11457 from Nelson Page, as well as an earlier report from Elvis
Pranskevichus, showed that there were still nasty bugs associated with such
cases: in particular the EquivalenceClass mechanism could try to generate
"join" clauses connecting an appendrel child to some grandparent appendrel,
which would result in assertion failures or bogus plans.

Upon investigation I concluded that all current callers of
find_childrel_appendrelinfo() need to be fixed to explicitly consider
multiple levels of parent appendrels.  The most complex fix was in
processing of "broken" EquivalenceClasses, which are ECs for which we have
been unable to generate all the derived equality clauses we would like to
because of missing cross-type equality operators in the underlying btree
operator family.  That code path is more or less entirely untested by
the regression tests to date, because no standard opfamilies have such
holes in them.  So I wrote a new regression test script to try to exercise
it a bit, which turned out to be quite a worthwhile activity as it exposed
existing bugs in all supported branches.

The present patch is essentially the same as far back as 9.2, which is
where parameterized paths were introduced.  In 9.0 and 9.1, we only need
to back-patch a small fragment of commit 5b7b5518d, which fixes failure to
propagate out the original WHERE clauses when a broken EC contains constant
members.  (The regression test case results show that these older branches
are noticeably stupider than 9.2+ in terms of the quality of the plans
generated; but we don't really care about plan quality in such cases,
only that the plan not be outright wrong.  A more invasive fix in the
older branches would not be a good idea anyway from a plan-stability
standpoint.)

9 years agoRefactor replication connection code of various pg_basebackup utilities.
Andres Freund [Wed, 1 Oct 2014 15:22:21 +0000 (17:22 +0200)]
Refactor replication connection code of various pg_basebackup utilities.

Move some more code to manage replication connection command to
streamutil.c. A later patch will introduce replication slot via
pg_receivexlog and this avoid duplicating relevant code between
pg_receivexlog and pg_recvlogical.

Author: Michael Paquier, with some editing by me.

9 years agopg_recvlogical.c code review.
Andres Freund [Mon, 29 Sep 2014 13:35:40 +0000 (15:35 +0200)]
pg_recvlogical.c code review.

Several comments still referred to 'initiating', 'freeing', 'stopping'
replication slots. These were terms used during different phases of
the development of logical decoding, but are no long accurate.

Also rename StreamLog() to StreamLogicalLog() and add 'void' to the
prototype.

Author: Michael Paquier, with some editing by me.

Backpatch to 9.4 where pg_recvlogical was introduced.

9 years agoRemove num_xloginsert_locks GUC, replace with a #define
Heikki Linnakangas [Wed, 1 Oct 2014 13:37:15 +0000 (16:37 +0300)]
Remove num_xloginsert_locks GUC, replace with a #define

I left the GUC in place for the beta period, so that people could experiment
with different values. No-one's come up with any data that a different value
would be better under some circumstances, so rather than try to document to
users what the GUC, let's just hard-code the current value, 8.