]> granicus.if.org Git - postgresql/log
postgresql
11 years agoFix PARAM_EXEC assignment mechanism to be safe in the presence of WITH.
Tom Lane [Wed, 5 Sep 2012 16:54:03 +0000 (12:54 -0400)]
Fix PARAM_EXEC assignment mechanism to be safe in the presence of WITH.

The planner previously assumed that parameter Vars having the same absolute
query level, varno, and varattno could safely be assigned the same runtime
PARAM_EXEC slot, even though they might be different Vars appearing in
different subqueries.  This was (probably) safe before the introduction of
CTEs, but the lazy-evalution mechanism used for CTEs means that a CTE can
be executed during execution of some other subquery, causing the lifespan
of Params at the same syntactic nesting level as the CTE to overlap with
use of the same slots inside the CTE.  In 9.1 we created additional hazards
by using the same parameter-assignment technology for nestloop inner scan
parameters, but it was broken before that, as illustrated by the added
regression test.

To fix, restructure the planner's management of PlannerParamItems so that
items having different semantic lifespans are kept rigorously separated.
This will probably result in complex queries using more runtime PARAM_EXEC
slots than before, but the slots are cheap enough that this hardly matters.
Also, stop generating PlannerParamItems containing Params for subquery
outputs: all we really need to do is reserve the PARAM_EXEC slot number,
and that now only takes incrementing a counter.  The planning code is
simpler and probably faster than before, as well as being more correct.

Per report from Vik Reykja.

These changes will mostly also need to be made in the back branches, but
I'm going to hold off on that until after 9.2.0 wraps.

11 years agoTrim spgist_private.h inclusion
Alvaro Herrera [Fri, 31 Aug 2012 21:04:31 +0000 (17:04 -0400)]
Trim spgist_private.h inclusion

It doesn't really need rel.h; relcache.h is enough.

11 years agoFix compiler warnings about unused variables, caused by my previous commit.
Heikki Linnakangas [Wed, 5 Sep 2012 05:07:35 +0000 (22:07 -0700)]
Fix compiler warnings about unused variables, caused by my previous commit.

Reported by Peter Eisentraut.

11 years agoIn pg_upgrade, document why we can't issue \n\n in the command logfile
Bruce Momjian [Wed, 5 Sep 2012 04:01:13 +0000 (00:01 -0400)]
In pg_upgrade, document why we can't issue \n\n in the command logfile
on Windows.  Slightly cleanup log output on Windows given this
restriction.

Backpatch to 9.2.

11 years agoFix bugs in cascading replication with recovery_target_timeline='latest'
Heikki Linnakangas [Wed, 5 Sep 2012 01:47:03 +0000 (18:47 -0700)]
Fix bugs in cascading replication with recovery_target_timeline='latest'

The cascading replication code assumed that the current RecoveryTargetTLI
never changes, but that's not true with recovery_target_timeline='latest'.
The obvious upshot of that is that RecoveryTargetTLI in shared memory needs
to be protected by a lock. A less obvious consequence is that when a
cascading standby is connected, and the standby switches to a new target
timeline after scanning the archive, it will continue to stream WAL to the
cascading standby, but from a wrong file, ie. the file of the previous
timeline. For example, if the standby is currently streaming from the middle
of file 000000010000000000000005, and the timeline changes, the standby
will continue to stream from that file. However, the WAL on the new
timeline is in file 000000020000000000000005, so the standby sends garbage
from 000000010000000000000005 to the cascading standby, instead of the
correct WAL from file 000000020000000000000005.

This also fixes a related bug where a partial WAL segment is restored from
the archive and streamed to a cascading standby. The code assumed that when
a WAL segment is copied from the archive, it can immediately be fully
streamed to a cascading standby. However, if the segment is only partially
filled, ie. has the right size, but only N first bytes contain valid WAL,
that's not safe. That can happen if a partial WAL segment is manually copied
to the archive, or if a partial WAL segment is archived because a server is
started up on a new timeline within that segment. The cascading standby will
get confused if the WAL it received is not valid, and will get stuck until
it's restarted. This patch fixes that problem by not allowing WAL restored
from the archive to be streamed to a cascading standby until it's been
replayed, and thus validated.

11 years agoFix serializable mode with index-only scans.
Kevin Grittner [Wed, 5 Sep 2012 02:13:11 +0000 (21:13 -0500)]
Fix serializable mode with index-only scans.

Serializable Snapshot Isolation used for serializable transactions
depends on acquiring SIRead locks on all heap relation tuples which
are used to generate the query result, so that a later delete or
update of any of the tuples can flag a read-write conflict between
transactions.  This is normally handled in heapam.c, with tuple level
locking.  Since an index-only scan avoids heap access in many cases,
building the result from the index tuple, the necessary predicate
locks were not being acquired for all tuples in an index-only scan.

To prevent problems with tuple IDs which are vacuumed and re-used
while the transaction still matters, the xmin of the tuple is part of
the tag for the tuple lock.  Since xmin is not available to the
index-only scan for result rows generated from the index tuples, it
is not possible to acquire a tuple-level predicate lock in such
cases, in spite of having the tid.  If we went to the heap to get the
xmin value, it would no longer be an index-only scan.  Rather than
prohibit index-only scans under serializable transaction isolation,
we acquire an SIRead lock on the page containing the tuple, when it
was not necessary to visit the heap for other reasons.

Backpatch to 9.2.

Kevin Grittner and Tom Lane

11 years agoAllow isolation tests to specify multiple setup blocks.
Kevin Grittner [Wed, 5 Sep 2012 00:31:06 +0000 (19:31 -0500)]
Allow isolation tests to specify multiple setup blocks.

Each setup block is run as a single PQexec submission, and some
statements such as VACUUM cannot be combined with others in such a
block.

Backpatch to 9.2.

Kevin Grittner and Tom Lane

11 years agoRemove src/tool/backend, now that the content is on the web site and wiki.
Bruce Momjian [Tue, 4 Sep 2012 16:38:33 +0000 (12:38 -0400)]
Remove src/tool/backend, now that the content is on the web site and wiki.

11 years agoFix transcription error.
Andrew Dunstan [Tue, 4 Sep 2012 13:39:49 +0000 (09:39 -0400)]
Fix transcription error.

11 years agoDocument that pg_upgrade requires PGHOST be set for any pre-9.1 servers
Bruce Momjian [Tue, 4 Sep 2012 13:17:19 +0000 (09:17 -0400)]
Document that pg_upgrade requires PGHOST be set for any pre-9.1 servers
with a socket directory mismatch with the new server.

Backpatch to 9.2.

11 years agoChange "restoring" to "processing" in message from pg_dump
Magnus Hagander [Tue, 4 Sep 2012 13:00:04 +0000 (15:00 +0200)]
Change "restoring" to "processing" in message from pg_dump

The same message is used in both pg_restore and pg_dump, and it's
confusing to output "restoring data for table xyz" when the user
is just doing a pg_dump.

11 years agoMention basebackup-from-slave next to cascading replication
Magnus Hagander [Tue, 4 Sep 2012 12:37:14 +0000 (14:37 +0200)]
Mention basebackup-from-slave next to cascading replication

11 years agoFix command echoing in pg_upgade's analyze script for Windows.
Andrew Dunstan [Tue, 4 Sep 2012 09:49:22 +0000 (05:49 -0400)]
Fix command echoing in pg_upgade's analyze script for Windows.

11 years agoRemove some useless trailing whitespace
Magnus Hagander [Tue, 4 Sep 2012 07:17:14 +0000 (09:17 +0200)]
Remove some useless trailing whitespace

Michael Paquier

11 years agoIndent fix_path_separator() header properly.
Andrew Dunstan [Tue, 4 Sep 2012 02:59:19 +0000 (22:59 -0400)]
Indent fix_path_separator() header properly.

11 years agoFix to_date() and to_timestamp() to allow specification of the day of
Bruce Momjian [Tue, 4 Sep 2012 02:52:34 +0000 (22:52 -0400)]
Fix to_date() and to_timestamp() to allow specification of the day of
the week via ISO or Gregorian designations.  The fix is to store the
day-of-week consistently as 1-7, Sunday = 1.

Fixes bug reported by Marc Munro

11 years agoAllow pg_upgrade "make check" to run on Windows/MSys.
Andrew Dunstan [Tue, 4 Sep 2012 02:32:17 +0000 (22:32 -0400)]
Allow pg_upgrade "make check" to run on Windows/MSys.

Backpatch to 9.2.

11 years agoIn pg_upgrade, pull the port number from postmaster.pid, like we do for
Bruce Momjian [Tue, 4 Sep 2012 02:15:09 +0000 (22:15 -0400)]
In pg_upgrade, pull the port number from postmaster.pid, like we do for
socket location.  Also, prevent putting the socket in the current
directory for pre-9.1 servers in live check and non-live check mode,
because pre-9.1 pg_ctl -w can't handle it.

Backpatch to 9.2.

11 years agoUse correct path separator for Windows builtin commands.
Andrew Dunstan [Mon, 3 Sep 2012 22:06:47 +0000 (18:06 -0400)]
Use correct path separator for Windows builtin commands.

pg_upgrade produces a platform-specific script to remove the old
directory, but on Windows it has not been making sure that the
paths it writes as arguments for rmdir and del use the backslash
path separator, which will cause these scripts to fail.

The fix is backpatched to Release 9.0.

11 years agoReplace memcpy() calls in xlog.c critical sections with struct assignments.
Tom Lane [Mon, 3 Sep 2012 19:38:42 +0000 (15:38 -0400)]
Replace memcpy() calls in xlog.c critical sections with struct assignments.

This gets rid of a dangerous-looking use of the not-volatile XLogCtl
pointer in a couple of spinlock-protected sections, where the normal
coding rule is that you should only access shared memory through a
pointer-to-volatile.  I think the risk is only hypothetical not actual,
since for there to be a bug the compiler would have to move the spinlock
acquire or release across the memcpy() call, which one sincerely hopes
it will not.  Still, it looks cleaner this way.

Per comment from Daniel Farina and subsequent discussion.

11 years agoFix bugs in exec.c that prevented pg_upgrade working in Windows.
Andrew Dunstan [Mon, 3 Sep 2012 19:31:26 +0000 (15:31 -0400)]
Fix bugs in exec.c that prevented pg_upgrade working in Windows.

Backpatch to 9.2 - code before that is quite different and should
not have these defects.

11 years agoFix pg_upgrade to cope with non-default unix_socket_directory scenarios.
Tom Lane [Mon, 3 Sep 2012 17:52:34 +0000 (13:52 -0400)]
Fix pg_upgrade to cope with non-default unix_socket_directory scenarios.

When starting either an old or new postmaster, force it to place its Unix
socket in the current directory.  This makes it even harder for accidental
connections to occur during pg_upgrade, and also works around some
scenarios where the default socket location isn't usable.  (For example,
if the default location is something other than "/tmp", it might not exist
during "make check".)

When checking an already-running old postmaster, find out its actual socket
directory location from postmaster.pid, if possible.  This dodges problems
with an old postmaster having a configured location different from the
default built into pg_upgrade's libpq.  We can't find that out if the old
postmaster is pre-9.1, so also document how to cope with such scenarios
manually.

In support of this, centralize handling of the connection-related command
line options passed to pg_upgrade's subsidiary programs, such as pg_dump.
This should make future changes easier.

Bruce Momjian and Tom Lane

11 years agoMake psql's \d+ show reloptions for all relkinds.
Tom Lane [Mon, 3 Sep 2012 15:24:31 +0000 (11:24 -0400)]
Make psql's \d+ show reloptions for all relkinds.

Formerly it would only show them for relkinds 'r' and 'f' (plain tables
and foreign tables).  However, as of 9.2, views can also have reloptions,
namely security_barrier.  The relkind restriction seems pointless and
not at all future-proof, so just print reloptions whenever there are any.

In passing, make some cosmetic improvements to the code that pulls the
"tableinfo" fields out of the PGresult.

Noted and patched by Dean Rasheed, with adjustment for all relkinds by me.

11 years agoUpdate URLs that pointed to sun.com; either repoint them or remove
Bruce Momjian [Sun, 2 Sep 2012 13:16:26 +0000 (09:16 -0400)]
Update URLs that pointed to sun.com;  either repoint them or remove
them.

11 years agoAdd small doc mention that libpq is named after POSTQUEL.
Bruce Momjian [Sun, 2 Sep 2012 12:41:51 +0000 (08:41 -0400)]
Add small doc mention that libpq is named after POSTQUEL.

11 years agoDrop cheap-startup-cost paths during add_path() if we don't need them.
Tom Lane [Sat, 1 Sep 2012 22:16:24 +0000 (18:16 -0400)]
Drop cheap-startup-cost paths during add_path() if we don't need them.

We can detect whether the planner top level is going to care at all about
cheap startup cost (it will only do so if query_planner's tuple_fraction
argument is greater than zero).  If it isn't, we might as well discard
paths immediately whose only advantage over others is cheap startup cost.
This turns out to get rid of quite a lot of paths in complex queries ---
I saw planner runtime reduction of more than a third on one large query.

Since add_path isn't currently passed the PlannerInfo "root", the easiest
way to tell it whether to do this was to add a bool flag to RelOptInfo.
That's a bit redundant, since all relations in a given query level will
have the same setting.  But in the future it's possible that we'd refine
the control decision to work on a per-relation basis, so this seems like
a good arrangement anyway.

Per my suggestion of a few months ago.

11 years agoFix mark_placeholder_maybe_needed to handle LATERAL references.
Tom Lane [Sat, 1 Sep 2012 17:56:14 +0000 (13:56 -0400)]
Fix mark_placeholder_maybe_needed to handle LATERAL references.

If a PlaceHolderVar contains a pulled-up LATERAL reference, its minimum
possible evaluation level might be higher in the join tree than its
original syntactic location.  That in turn affects the ph_needed level for
any contained PlaceHolderVars (that is, those PHVs had better propagate up
the join tree at least to the evaluation level of the outer PHV).  We got
this mostly right, but mark_placeholder_maybe_needed() failed to account
for the effect, and in consequence could leave the inner PHVs with
ph_may_need less than what their ultimate ph_needed value will be.  That's
bad because it could lead to failure to select a join order that will allow
evaluation of the inner PHV at a valid location.  Fix that, and add an
Assert that checks that we don't ever set ph_needed to more than
ph_may_need.

11 years agoRevert doc patch 305557984dd964ac397c6752e9d0f14646b60f15 as the values
Bruce Momjian [Sat, 1 Sep 2012 16:04:44 +0000 (12:04 -0400)]
Revert doc patch 305557984dd964ac397c6752e9d0f14646b60f15 as the values
are sometimes signed, sometimes unsigned.

11 years agoFix broken link in installation.sgml.
Tom Lane [Sat, 1 Sep 2012 14:43:50 +0000 (10:43 -0400)]
Fix broken link in installation.sgml.

Linking to other parts of the manual doesn't work when building the
standalone INSTALL document.

11 years agoCross-link to doc build requirements from install requirements.
Robert Haas [Sat, 1 Sep 2012 10:27:52 +0000 (06:27 -0400)]
Cross-link to doc build requirements from install requirements.

Jeff Janes

11 years agoMore documentation updates for LATERAL.
Tom Lane [Sat, 1 Sep 2012 04:40:15 +0000 (00:40 -0400)]
More documentation updates for LATERAL.

Extend xfunc.sgml's discussion of set-returning functions to show an
example of using LATERAL, and recommend that over putting SRFs in the
targetlist.

In passing, reword func.sgml's section on set-returning functions so
that it doesn't claim that the functions listed therein are all the
built-in set-returning functions.  That hasn't been true for a long
time, and trying to make it so doesn't seem like it would be an
improvement.  (Perhaps we should rename that section?)

Both per suggestions from Merlin Moncure.

11 years agopsql: Reduce compatibility warning
Peter Eisentraut [Sat, 1 Sep 2012 03:28:14 +0000 (23:28 -0400)]
psql: Reduce compatibility warning

Only warn when connecting to a newer server, since connecting to older
servers works pretty well nowadays.  Also update the documentation a
little about current psql/server compatibility expectations.

11 years agoRestore setting of _USE_32BIT_TIME_T to 32 bit MSVC builds.
Andrew Dunstan [Sat, 1 Sep 2012 00:38:37 +0000 (20:38 -0400)]
Restore setting of _USE_32BIT_TIME_T to 32 bit MSVC builds.

This was removed in commit cd004067742ee16ee63e55abfb4acbd5f09fbaab,
we're not quite sure why, but there have been reports of crashes due
to AS Perl being built with it when we are not, and it certainly
seems like the right thing to do. There is still some uncertainty
as to why it sometimes fails and sometimes doesn't.

Original patch from Owais Khani, substantially reworked and
extended by Andrew Dunstan.

11 years agoPartially restore qual scope checks in distribute_qual_to_rels().
Tom Lane [Fri, 31 Aug 2012 22:57:12 +0000 (18:57 -0400)]
Partially restore qual scope checks in distribute_qual_to_rels().

The LATERAL implementation is now basically complete, and I still don't
see a cost-effective way to make an exact qual scope cross-check in the
presence of LATERAL.  However, I did add a PlannerInfo.hasLateralRTEs flag
along the way, so it's easy to make the check only when not hasLateralRTEs.
That seems to still be useful, and it beats having no check at all.

11 years agoFix LATERAL references to join alias variables.
Tom Lane [Fri, 31 Aug 2012 21:44:01 +0000 (17:44 -0400)]
Fix LATERAL references to join alias variables.

I had thought this case worked already, but perhaps I didn't re-test it
after adding extract_lateral_references() ...

11 years agoIn pg_upgade, document that the port numbers must be different when
Bruce Momjian [Fri, 31 Aug 2012 20:55:49 +0000 (16:55 -0400)]
In pg_upgade, document that the port numbers must be different when
checking an old running server.

11 years agoMake configure probe for mbstowcs_l as well as wcstombs_l.
Tom Lane [Fri, 31 Aug 2012 18:17:56 +0000 (14:17 -0400)]
Make configure probe for mbstowcs_l as well as wcstombs_l.

We previously supposed that any given platform would supply both or neither
of these functions, so that one configure test would be sufficient.  It now
appears that at least on AIX this is not the case ... which is likely an
AIX bug, but nonetheless we need to cope with it.  So use separate tests.
Per bug #6758; thanks to Andrew Hastie for doing the followup testing
needed to confirm what was happening.

Backpatch to 9.1, where we began using these functions.

11 years agoFix typos in README.
Heikki Linnakangas [Fri, 31 Aug 2012 08:30:11 +0000 (11:30 +0300)]
Fix typos in README.

11 years agoImprove coding of gistchoose and gistRelocateBuildBuffersOnSplit.
Tom Lane [Fri, 31 Aug 2012 02:52:43 +0000 (22:52 -0400)]
Improve coding of gistchoose and gistRelocateBuildBuffersOnSplit.

This is mostly cosmetic, but it does eliminate a speculative portability
issue.  The previous coding ignored the fact that sum_grow could easily
overflow (in fact, it could be summing multiple IEEE float infinities).
On a platform where that didn't guarantee to produce a positive result,
the code would misbehave.  In any case, it was less than readable.

11 years agoAdd Perl emacs formatting macros to src/tools/editors/emacs.samples.
Bruce Momjian [Fri, 31 Aug 2012 01:40:31 +0000 (21:40 -0400)]
Add Perl emacs formatting macros to src/tools/editors/emacs.samples.

Peter Eisentraut

11 years agoClarify FreeBSD instructions in pg_test_timing.
Bruce Momjian [Thu, 30 Aug 2012 22:38:00 +0000 (18:38 -0400)]
Clarify FreeBSD instructions in pg_test_timing.

Josh Kupershmidt

11 years agoProperly document that SIGTERM is OK for users to use on a postgres
Bruce Momjian [Thu, 30 Aug 2012 21:58:36 +0000 (17:58 -0400)]
Properly document that SIGTERM is OK for users to use on a postgres
session, now that pg_terminate_backend() uses it.

Josh Kupershmidt

11 years agoRevert 1fbc30f1dca6624c01a9a6a9ff711a7036c68532 because the
Bruce Momjian [Thu, 30 Aug 2012 21:05:51 +0000 (17:05 -0400)]
Revert 1fbc30f1dca6624c01a9a6a9ff711a7036c68532 because the
--enable-shared is about Plyton's configure, not ours.

11 years agoRemove doc mention of --enable-shared, per Tom.
Bruce Momjian [Thu, 30 Aug 2012 21:00:51 +0000 (17:00 -0400)]
Remove doc mention of --enable-shared, per Tom.

11 years agoDocument that max_locks_per_transaction might need to be increased for
Bruce Momjian [Thu, 30 Aug 2012 20:56:12 +0000 (16:56 -0400)]
Document that max_locks_per_transaction might need to be increased for
queries on parent tables, per suggestion from Josh Berkus.

11 years agoSplit tuple struct defs from htup.h to htup_details.h
Alvaro Herrera [Thu, 30 Aug 2012 20:15:44 +0000 (16:15 -0400)]
Split tuple struct defs from htup.h to htup_details.h

This reduces unnecessary exposure of other headers through htup.h, which
is very widely included by many files.

I have chosen to move the function prototypes to the new file as well,
because that means htup.h no longer needs to include tupdesc.h.  In
itself this doesn't have much effect in indirect inclusion of tupdesc.h
throughout the tree, because it's also required by execnodes.h; but it's
something to explore in the future, and it seemed best to do the htup.h
change now while I'm busy with it.

11 years agoRemove configure flag --disable-shared, as it is no longer used by any
Bruce Momjian [Thu, 30 Aug 2012 20:26:53 +0000 (16:26 -0400)]
Remove configure flag --disable-shared, as it is no longer used by any
port.  The last use was QNX, per Peter Eisentraut.

11 years agoFix checkpoint_timeout documentation to reflect current behavior.
Robert Haas [Thu, 30 Aug 2012 19:06:55 +0000 (15:06 -0400)]
Fix checkpoint_timeout documentation to reflect current behavior.

Jeff Janes

11 years agoDocument that log_autovacuum_min_duration can be used to monitor
Bruce Momjian [Thu, 30 Aug 2012 18:44:36 +0000 (14:44 -0400)]
Document that log_autovacuum_min_duration can be used to monitor
autovacuum activity.

Per report from Marc Mamin

11 years agoSuppress creation of backwardly-indexed paths for LATERAL join clauses.
Tom Lane [Thu, 30 Aug 2012 18:32:22 +0000 (14:32 -0400)]
Suppress creation of backwardly-indexed paths for LATERAL join clauses.

Given a query such as

SELECT * FROM foo JOIN LATERAL (SELECT foo.var1) ss(x) ON ss.x = foo.var2

the existence of the join clause "ss.x = foo.var2" encourages indxpath.c to
build a parameterized path for foo using any index available for foo.var2.
This is completely useless activity, though, since foo has got to be on the
outside not the inside of any nestloop join with ss.  It's reasonably
inexpensive to add tests that prevent creation of such paths, so let's do
that.

11 years agoDocument how to prevent PostgreSQL itself from exhausting memory.
Robert Haas [Thu, 30 Aug 2012 18:14:22 +0000 (14:14 -0400)]
Document how to prevent PostgreSQL itself from exhausting memory.

The existing documentation in Linux Memory Overcommit seemed to
assume that PostgreSQL itself could never be the problem, or at
least it didn't tell you what to do about it.

Per discussion with Craig Ringer and Kevin Grittner.

11 years agoFix division by zero in the new range type histogram creation.
Heikki Linnakangas [Thu, 30 Aug 2012 17:27:19 +0000 (20:27 +0300)]
Fix division by zero in the new range type histogram creation.

Report and analysis by Matthias.

11 years agoAdd missing period to detail message.
Robert Haas [Thu, 30 Aug 2012 17:26:45 +0000 (13:26 -0400)]
Add missing period to detail message.

Per note from Peter Eisentraut.

11 years agoDocument that COPY OUT requires an absolute pathname.
Robert Haas [Thu, 30 Aug 2012 17:17:21 +0000 (13:17 -0400)]
Document that COPY OUT requires an absolute pathname.

As suggested by Etsuro Fujita, but with somewhat different wording.

11 years agoRemove old documentation warnings about the use of bigint.
Bruce Momjian [Thu, 30 Aug 2012 17:13:35 +0000 (13:13 -0400)]
Remove old documentation warnings about the use of bigint.

11 years agoFix logic bug in gistchoose and gistRelocateBuildBuffersOnSplit.
Robert Haas [Thu, 30 Aug 2012 17:05:45 +0000 (13:05 -0400)]
Fix logic bug in gistchoose and gistRelocateBuildBuffersOnSplit.

Every time the best-tuple-found-so-far changes, we need to reset all
the penalty values in which_grow[] to the penalties for the new best
tuple.  The old code failed to do this, resulting in inferior index
quality.

The original patch from Alexander Korotkov was just two lines; I took
the liberty of fleshing that out by adding a bunch of comments that I
hope will make this logic easier for others to understand than it was
for me.

11 years agoImprove EXPLAIN's ability to cope with LATERAL references in plans.
Tom Lane [Thu, 30 Aug 2012 16:56:50 +0000 (12:56 -0400)]
Improve EXPLAIN's ability to cope with LATERAL references in plans.

push_child_plan/pop_child_plan didn't bother to adjust the "ancestors"
list of parent plan nodes when descending to a child plan node.  I think
this was okay when it was written, but it's not okay in the presence of
LATERAL references, since a subplan node could easily be returning a
LATERAL value back up to the same nestloop node that provides the value.
Per changed regression test results, the omission led to failure to
interpret Param nodes that have perfectly good interpretations.

11 years agoComment fixes.
Robert Haas [Thu, 30 Aug 2012 14:42:28 +0000 (10:42 -0400)]
Comment fixes.

Jeff Davis, somewhat edited by me

11 years agoDocument that xslt-related RPMs may be needed to build docs.
Robert Haas [Thu, 30 Aug 2012 14:37:46 +0000 (10:37 -0400)]
Document that xslt-related RPMs may be needed to build docs.

11 years agoAlso check for Python platform-specific include directory
Peter Eisentraut [Thu, 30 Aug 2012 02:44:59 +0000 (22:44 -0400)]
Also check for Python platform-specific include directory

Python can be built to have two separate include directories: one for
platform-independent files and one for platform-specific files.  So
far, this has apparently never mattered for a PL/Python build.  But
with the new multi-arch Python packages in Debian and Ubuntu, this is
becoming the standard configuration on these platforms, so we must
check these directories separately to be able to build there.

Also add a bit of reporting in configure to be able to see better what
is going on with this.

11 years agoAdjust definition of cheapest_total_path to work better with LATERAL.
Tom Lane [Thu, 30 Aug 2012 02:05:27 +0000 (22:05 -0400)]
Adjust definition of cheapest_total_path to work better with LATERAL.

In the initial cut at LATERAL, I kept the rule that cheapest_total_path
was always unparameterized, which meant it had to be NULL if the relation
has no unparameterized paths.  It turns out to work much more nicely if
we always have *some* path nominated as cheapest-total for each relation.
In particular, let's still say it's the cheapest unparameterized path if
there is one; if not, take the cheapest-total-cost path among those of
the minimum available parameterization.  (The first rule is actually
a special case of the second.)

This allows reversion of some temporary lobotomizations I'd put in place.
In particular, the planner can now consider hash and merge joins for
joins below a parameter-supplying nestloop, even if there aren't any
unparameterized paths available.  This should bring planning of
LATERAL-containing queries to the same level as queries not using that
feature.

Along the way, simplify management of parameterized paths in add_path()
and friends.  In the original coding for parameterized paths in 9.2,
I tried to minimize the logic changes in add_path(), so it just treated
parameterization as yet another dimension of comparison for paths.
We later made it ignore pathkeys (sort ordering) of parameterized paths,
on the grounds that ordering isn't a useful property for the path on the
inside of a nestloop, so we might as well get rid of useless parameterized
paths as quickly as possible.  But we didn't take that reasoning as far as
we should have.  Startup cost isn't a useful property inside a nestloop
either, so add_path() ought to discount startup cost of parameterized paths
as well.  Having done that, the secondary sorting I'd implemented (in
add_parameterized_path) is no longer needed --- any parameterized path that
survives add_path() at all is worth considering at higher levels.  So this
should be a bit faster as well as simpler.

11 years agoDocument that NOTIFY events are visible to all users.
Bruce Momjian [Thu, 30 Aug 2012 01:45:31 +0000 (21:45 -0400)]
Document that NOTIFY events are visible to all users.

11 years agoReport postmaster.pid file as empty if it is empty, rather than
Bruce Momjian [Wed, 29 Aug 2012 21:05:22 +0000 (17:05 -0400)]
Report postmaster.pid file as empty if it is empty, rather than
reporting in contains invalid data.

11 years agoOptimize SP-GiST insertions.
Heikki Linnakangas [Wed, 29 Aug 2012 06:14:08 +0000 (09:14 +0300)]
Optimize SP-GiST insertions.

This includes two micro-optimizations to the tight inner loop in descending
the SP-GiST tree: 1. avoid an extra function call to index_getprocinfo when
calling user-defined choose function, and 2. avoid a useless palloc+pfree
when node labels are not used.

11 years agoFix assorted compilation failures in contrib
Alvaro Herrera [Wed, 29 Aug 2012 03:43:09 +0000 (23:43 -0400)]
Fix assorted compilation failures in contrib

Evidently I failed to test a compile after my earlier header shuffling.

11 years agoAdd strerror() string to chdir() error message
Peter Eisentraut [Wed, 29 Aug 2012 03:01:23 +0000 (23:01 -0400)]
Add strerror() string to chdir() error message

11 years agoSplit heapam_xlog.h from heapam.h
Alvaro Herrera [Tue, 28 Aug 2012 23:02:00 +0000 (19:02 -0400)]
Split heapam_xlog.h from heapam.h

The heapam XLog functions are used by other modules, not all of which
are interested in the rest of the heapam API.  With this, we let them
get just the XLog stuff in which they are interested and not pollute
them with unrelated includes.

Also, since heapam.h no longer requires xlog.h, many files that do
include heapam.h no longer get xlog.h automatically, including a few
headers.  This is useful because heapam.h is getting pulled in by
execnodes.h, which is in turn included by a lot of files.

11 years agoremove catcache.h from syscache.h
Alvaro Herrera [Tue, 28 Aug 2012 22:26:24 +0000 (18:26 -0400)]
remove catcache.h from syscache.h

Instead, place a forward struct declaration for struct catclist in
syscache.h.  This reduces header proliferation somewhat.

11 years agoSplit resowner.h
Alvaro Herrera [Tue, 28 Aug 2012 22:02:07 +0000 (18:02 -0400)]
Split resowner.h

This lets files that are mere users of ResourceOwner not automatically
include the headers for stuff that is managed by the resowner mechanism.

11 years agoadd #includes to plpy_subxactobject.h to make it compile standalone
Alvaro Herrera [Tue, 28 Aug 2012 20:11:44 +0000 (16:11 -0400)]
add #includes to plpy_subxactobject.h to make it compile standalone

11 years agoRemove pg_stat_statements--1.0.sql, too.
Tom Lane [Tue, 28 Aug 2012 18:33:56 +0000 (14:33 -0400)]
Remove pg_stat_statements--1.0.sql, too.

Per Peter Geoghegan.

11 years agoRemove hstore--1.0.sql.
Tom Lane [Tue, 28 Aug 2012 18:29:55 +0000 (14:29 -0400)]
Remove hstore--1.0.sql.

Since we're not installing this file anymore, it has no reason to exist,
other than as historical reference; but we have an SCM for that.

11 years agoAdjust pg_test_timing to show shortest test durations first, place
Bruce Momjian [Tue, 28 Aug 2012 16:57:13 +0000 (12:57 -0400)]
Adjust pg_test_timing to show shortest test durations first, place
percentage column before count column.  Docs updated.

11 years agoPrevent psql tab completion in SET from adding TO when the equals sign
Bruce Momjian [Tue, 28 Aug 2012 16:53:31 +0000 (12:53 -0400)]
Prevent psql tab completion in SET from adding TO when the equals sign
has no space before it.

Report by Erik Rijkers

11 years agoUpdate doc mention of how to compute bigint advisory lock value, per Tom
Bruce Momjian [Tue, 28 Aug 2012 16:17:11 +0000 (12:17 -0400)]
Update doc mention of how to compute bigint advisory lock value, per Tom
Lane's correction.

11 years agosyncrep.h must include xlogdefs.h
Alvaro Herrera [Tue, 28 Aug 2012 13:46:08 +0000 (09:46 -0400)]
syncrep.h must include xlogdefs.h

11 years agoSmall punctuation fixes
Peter Eisentraut [Tue, 28 Aug 2012 07:10:04 +0000 (03:10 -0400)]
Small punctuation fixes

11 years agoDocument how to create advisory lock "bigint" values in SQL.
Bruce Momjian [Tue, 28 Aug 2012 02:36:37 +0000 (22:36 -0400)]
Document how to create advisory lock "bigint" values in SQL.

David E. Wheeler

11 years agoImprove a couple of 9.2 release note entries.
Tom Lane [Tue, 28 Aug 2012 00:53:57 +0000 (20:53 -0400)]
Improve a couple of 9.2 release note entries.

Clarify the compatibility notes about EXTRACT() and about statistics
timing columns.

11 years agoAdd section IDs to subsections of syntax.sgml that lacked them.
Tom Lane [Tue, 28 Aug 2012 00:17:12 +0000 (20:17 -0400)]
Add section IDs to subsections of syntax.sgml that lacked them.

This is so that these sections will have stable HTML tags that one can
link to, rather than things like "AEN1902".  Perhaps we should mount a
campaign to do this everywhere, but I've found myself pointing at
syntax.sgml subsections often enough to be sure it's useful here.

11 years agoDocument the lack of reading the PGDATABASE environment variable in
Bruce Momjian [Mon, 27 Aug 2012 19:26:53 +0000 (15:26 -0400)]
Document the lack of reading the PGDATABASE environment variable in
pg_restore.

11 years agopg_upgrade: Fix exec_prog API to be less flaky
Alvaro Herrera [Mon, 27 Aug 2012 18:21:09 +0000 (14:21 -0400)]
pg_upgrade: Fix exec_prog API to be less flaky

The previous signature made it very easy to pass something other than
the printf-format specifier in the corresponding position, without any
warning from the compiler.

While at it, move some of the escaping, redirecting and quoting
responsibilities from the callers into exec_prog() itself.  This makes
the callsites cleaner.

11 years agoFix thinko in comment
Alvaro Herrera [Mon, 27 Aug 2012 18:20:28 +0000 (14:20 -0400)]
Fix thinko in comment

It was confusing symlinks with hard links.

11 years agoRemove analyze_new_cluster.sh on make clean, too
Alvaro Herrera [Mon, 27 Aug 2012 16:42:59 +0000 (12:42 -0400)]
Remove analyze_new_cluster.sh on make clean, too

11 years agoFix DROP INDEX CONCURRENTLY IF EXISTS.
Tom Lane [Mon, 27 Aug 2012 16:45:43 +0000 (12:45 -0400)]
Fix DROP INDEX CONCURRENTLY IF EXISTS.

This threw ERROR, not the expected NOTICE, if the index didn't exist.
The bug was actually visible in not-as-expected regression test output,
so somebody wasn't paying too close attention in commit
8cb53654dbdb4c386369eb988062d0bbb6de725e.
Per report from Brendan Byrd.

11 years agoHave pgindent requre pg_bsd_indent version 1.2 now that a new version
Bruce Momjian [Mon, 27 Aug 2012 13:31:45 +0000 (09:31 -0400)]
Have pgindent requre pg_bsd_indent version 1.2 now that a new version
has been created by adding #include <stdlib.h> to parse.c.

per request from Kevin Grittner.

11 years agoCollect and use histograms of lower and upper bounds for range types.
Heikki Linnakangas [Mon, 27 Aug 2012 12:48:46 +0000 (15:48 +0300)]
Collect and use histograms of lower and upper bounds for range types.

This enables selectivity estimation of the <<, >>, &<, &> and && operators,
as well as the normal inequality operators: <, <=, >=, >. "range @> element"
is also supported, but the range-variant @> and <@ operators are not,
because they cannot be sensibly estimated with lower and upper bound
histograms alone. We would need to make some assumption about the lengths of
the ranges for that. Alexander's patch included a separate histogram of
lengths for that, but I left that out of the patch for simplicity. Hopefully
that will be added as a followup patch.

The fraction of empty ranges is also calculated and used in estimation.

Alexander Korotkov, heavily modified by me.

11 years agopg_basebackup: Correct error message
Peter Eisentraut [Mon, 27 Aug 2012 04:49:39 +0000 (00:49 -0400)]
pg_basebackup: Correct error message

It still thought that the --xlog-method option argument could be
empty, as in a previous version of this feature.

11 years agoUpdate FreeBSD kernel configuration documentation.
Bruce Momjian [Mon, 27 Aug 2012 03:21:45 +0000 (23:21 -0400)]
Update FreeBSD kernel configuration documentation.

Brad Davis

11 years agoFix up planner infrastructure to support LATERAL properly.
Tom Lane [Mon, 27 Aug 2012 02:48:55 +0000 (22:48 -0400)]
Fix up planner infrastructure to support LATERAL properly.

This patch takes care of a number of problems having to do with failure
to choose valid join orders and incorrect handling of lateral references
pulled up from subqueries.  Notable changes:

* Add a LateralJoinInfo data structure similar to SpecialJoinInfo, to
represent join ordering constraints created by lateral references.
(I first considered extending the SpecialJoinInfo structure, but the
semantics are different enough that a separate data structure seems
better.)  Extend join_is_legal() and related functions to prevent trying
to form unworkable joins, and to ensure that we will consider joins that
satisfy lateral references even if the joins would be clauseless.

* Fill in the infrastructure needed for the last few types of relation scan
paths to support parameterization.  We'd have wanted this eventually
anyway, but it is necessary now because a relation that gets pulled up out
of a UNION ALL subquery may acquire a reltargetlist containing lateral
references, meaning that its paths *have* to be parameterized whether or
not we have any code that can push join quals down into the scan.

* Compute data about lateral references early in query_planner(), and save
in RelOptInfo nodes, to avoid repetitive calculations later.

* Assorted corner-case bug fixes.

There's probably still some bugs left, but this is a lot closer to being
real than it was before.

11 years agoClarify documentation that primary key and unique constraints are copied
Bruce Momjian [Sun, 26 Aug 2012 20:33:11 +0000 (16:33 -0400)]
Clarify documentation that primary key and unique constraints are copied
for CREATE TABLE LIKE ... INCLUDING INDEXES.

Per report from david.sahagian@emc.com

11 years agoUse psql_error() for most psql error calls, per request from Magnus.
Bruce Momjian [Sun, 26 Aug 2012 02:58:42 +0000 (22:58 -0400)]
Use psql_error() for most psql error calls, per request from Magnus.

11 years agoDocument clearly that psql \! parameter interpretation limitations are
Bruce Momjian [Sat, 25 Aug 2012 23:11:21 +0000 (19:11 -0400)]
Document clearly that psql \! parameter interpretation limitations are
the same as \copy.

11 years agoAllow text timezone designations, e.g. "America/Chicago", when using the
Bruce Momjian [Sat, 25 Aug 2012 21:44:53 +0000 (17:44 -0400)]
Allow text timezone designations, e.g. "America/Chicago", when using the
ISO "T" timestamptz format.

11 years agoSome spelling adjustments in release notes
Peter Eisentraut [Sat, 25 Aug 2012 02:36:24 +0000 (22:36 -0400)]
Some spelling adjustments in release notes

11 years agoNormalize some British spellings
Peter Eisentraut [Sat, 25 Aug 2012 02:35:53 +0000 (22:35 -0400)]
Normalize some British spellings

11 years agoFix issues with checks for unsupported transaction states in Hot Standby.
Tom Lane [Fri, 24 Aug 2012 17:09:04 +0000 (13:09 -0400)]
Fix issues with checks for unsupported transaction states in Hot Standby.

The GUC check hooks for transaction_read_only and transaction_isolation
tried to check RecoveryInProgress(), so as to disallow setting read/write
mode or serializable isolation level (respectively) in hot standby
sessions.  However, GUC check hooks can be called in many situations where
we're not connected to shared memory at all, resulting in a crash in
RecoveryInProgress().  Among other cases, this results in EXEC_BACKEND
builds crashing during child process start if default_transaction_isolation
is serializable, as reported by Heikki Linnakangas.  Protect those calls
by silently allowing any setting when not inside a transaction; which is
okay anyway since these GUCs are always reset at start of transaction.

Also, add a check to GetSerializableTransactionSnapshot() to complain
if we are in hot standby.  We need that check despite the one in
check_XactIsoLevel() because default_transaction_isolation could be
serializable.  We don't want to complain any sooner than this in such
cases, since that would prevent running transactions at all in such a
state; but a transaction can be run, if SET TRANSACTION ISOLATION is done
before setting a snapshot.  Per report some months ago from Robert Haas.

Back-patch to 9.1, since these problems were introduced by the SSI patch.

Kevin Grittner and Tom Lane, with ideas from Heikki Linnakangas

11 years agoPut options on man page and in help output in slightly better order
Peter Eisentraut [Fri, 24 Aug 2012 04:06:59 +0000 (00:06 -0400)]
Put options on man page and in help output in slightly better order

11 years agolibpq: Fix memory leak in URI parser
Peter Eisentraut [Fri, 24 Aug 2012 02:33:04 +0000 (22:33 -0400)]
libpq: Fix memory leak in URI parser

When an invalid query parameter is reported, some memory leaks.

found by Coverity

11 years agoFix cascading privilege revoke to notice when privileges are still held.
Tom Lane [Thu, 23 Aug 2012 21:25:10 +0000 (17:25 -0400)]
Fix cascading privilege revoke to notice when privileges are still held.

If we revoke a grant option from some role X, but X still holds the option
via another grant, we should not recursively revoke the privilege from
role(s) Y that X had granted it to.  This was supposedly fixed as one
aspect of commit 4b2dafcc0b1a579ef5daaa2728223006d1ff98e9, but I must not
have tested it, because in fact that code never worked: it forgot to shift
the grant-option bits back over when masking the bits being revoked.

Per bug #6728 from Daniel German.  Back-patch to all active branches,
since this has been wrong since 8.0.