]> granicus.if.org Git - postgresql/log
postgresql
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.

11 years agoFix typo in example.
Heikki Linnakangas [Thu, 23 Aug 2012 08:57:34 +0000 (11:57 +0300)]
Fix typo in example.

11 years agoAdd instructions for setting up documentation tool chain on Mac OS X
Peter Eisentraut [Thu, 23 Aug 2012 06:28:47 +0000 (02:28 -0400)]
Add instructions for setting up documentation tool chain on Mac OS X

11 years agopg_upgrade: Run the created scripts in the test suite
Peter Eisentraut [Thu, 23 Aug 2012 06:27:36 +0000 (02:27 -0400)]
pg_upgrade: Run the created scripts in the test suite

Just to check that they actually work.

11 years agoRemove overly-pessimistic statement about constraint exclusion.
Tom Lane [Thu, 23 Aug 2012 03:55:34 +0000 (23:55 -0400)]
Remove overly-pessimistic statement about constraint exclusion.

As of 9.2, constraint exclusion should work okay with prepared statements:
the planner will try custom plans with actual values of the parameters,
and observe that they are a lot cheaper than the generic plan, and thus
never fall back to using the generic plan.  Noted by Tatsuhito Kasahara.

11 years agoMake a cut at a major-features list for 9.2.
Tom Lane [Wed, 22 Aug 2012 21:58:06 +0000 (17:58 -0400)]
Make a cut at a major-features list for 9.2.

This is open to debate of course, but it's past time we had *something*
here.

11 years agoMake an editorial pass over the 9.2 release notes.
Tom Lane [Wed, 22 Aug 2012 21:37:02 +0000 (17:37 -0400)]
Make an editorial pass over the 9.2 release notes.

A very large number of small improvements ...

11 years agoFix erroneous documentation of synchronous_commit = remote_write.
Tom Lane [Wed, 22 Aug 2012 18:04:02 +0000 (14:04 -0400)]
Fix erroneous documentation of synchronous_commit = remote_write.

The docs claimed that this mode only waits for the standby to receive WAL
data, but actually it waits for the data to be written out to the standby's
OS; which is a pretty significant difference because it removes the risk of
crash of the walreceiver process.

11 years agoFix typo.
Bruce Momjian [Wed, 22 Aug 2012 16:05:25 +0000 (12:05 -0400)]
Fix typo.

11 years agoDocument that pg_reload_conf() is also an easy way to reload the
Bruce Momjian [Wed, 22 Aug 2012 16:00:24 +0000 (12:00 -0400)]
Document that pg_reload_conf() is also an easy way to reload the
configuration file.

11 years agoFix install-strip on Mac OS X
Peter Eisentraut [Wed, 22 Aug 2012 03:42:43 +0000 (23:42 -0400)]
Fix install-strip on Mac OS X

There was a hack put into install-sh to call strip with the correct
options on Mac OS X.  But that never worked, because configure
disabled stripping on that platform altogether.  So remove that dead
code, and while we're at it, update install-sh to the latest upstream
source (from Automake).

Instead, set up the right strip options in programs.m4, so this now
actually works the way it was originally intended.

11 years agoMark DateTimeParseError() noreturn
Peter Eisentraut [Wed, 22 Aug 2012 03:30:05 +0000 (23:30 -0400)]
Mark DateTimeParseError() noreturn

This avoids a warning from clang 3.2 about an uninitialized variable
'dtype' in date_in().

11 years agoUpdate 9.2 release notes to reflect commits to date.
Tom Lane [Wed, 22 Aug 2012 02:56:10 +0000 (22:56 -0400)]
Update 9.2 release notes to reflect commits to date.

I was unable to entirely resist the temptation to copy-edit related
entries, but will save most of that for a separate pass.

11 years agoAvoid somewhat-theoretical overflow risks in RecordIsValid().
Tom Lane [Tue, 21 Aug 2012 22:41:52 +0000 (18:41 -0400)]
Avoid somewhat-theoretical overflow risks in RecordIsValid().

This improves on commit 51fed14d73ed3acd2282b531fb1396877e44e86a by
eliminating the assumption that we can form <some pointer value> +
<some offset> without overflow.  The entire point of those tests is that
we don't trust the offset value, so coding them in a way that could wrap
around if the buffer happens to be near the top of memory doesn't seem
sound.  Instead, track the remaining space as a size_t variable and
compare offsets against that.

Also, improve comment about why we need the extra early check on
xl_tot_len.

11 years agoFix dumping of security_barrier views with circular dependencies.
Tom Lane [Tue, 21 Aug 2012 19:18:36 +0000 (15:18 -0400)]
Fix dumping of security_barrier views with circular dependencies.

If a view has circular dependencies, pg_dump splits it into a CREATE TABLE
and a CREATE RULE command to break the dependency loop.  However, if the
view has reloptions, those options cannot be applied in the CREATE TABLE
command, because views and tables have different allowed reloptions so
CREATE TABLE would reject them.  Instead apply the reloptions after the
CREATE RULE, using ALTER VIEW SET.

11 years agoImprove C comments in GetSnapshotData.
Robert Haas [Tue, 21 Aug 2012 15:47:10 +0000 (11:47 -0400)]
Improve C comments in GetSnapshotData.

Move discussion of why our algorithm for taking snapshots in recovery
to a more appropriate location in the function, and delete incorrect
mention of taking a lock.

11 years agoAdd a note to the MVCC chapter that some things aren't transactional.
Robert Haas [Tue, 21 Aug 2012 15:08:15 +0000 (11:08 -0400)]
Add a note to the MVCC chapter that some things aren't transactional.

Craig Ringer, slightly edited by me.

11 years agoTeach compiler that ereport(>=ERROR) does not return
Peter Eisentraut [Tue, 21 Aug 2012 04:03:32 +0000 (00:03 -0400)]
Teach compiler that ereport(>=ERROR) does not return

When elevel >= ERROR, we add an abort() call to the ereport() macro to
give the compiler a hint that the ereport() expansion will not return,
but the abort() isn't actually reached because the longjmp happens in
errfinish().

Because the effect of ereport() varies with the elevel, we cannot use
standard compiler attributes such as noreturn for this.

11 years agoRemove external PID file on postmaster exit
Peter Eisentraut [Tue, 21 Aug 2012 03:47:11 +0000 (23:47 -0400)]
Remove external PID file on postmaster exit

11 years agoImproved tab completion for CLUSTER VERBOSE.
Robert Haas [Mon, 20 Aug 2012 20:45:44 +0000 (16:45 -0400)]
Improved tab completion for CLUSTER VERBOSE.

Jeff Janes

11 years agoTab complete "TABLE whatever DROP CONSTRAINT" with a constraint name.
Robert Haas [Mon, 20 Aug 2012 20:30:08 +0000 (16:30 -0400)]
Tab complete "TABLE whatever DROP CONSTRAINT" with a constraint name.

Jeff Janes

11 years agoFix bugs in contrib/pg_trgm's LIKE pattern analysis code.
Tom Lane [Mon, 20 Aug 2012 17:24:52 +0000 (13:24 -0400)]
Fix bugs in contrib/pg_trgm's LIKE pattern analysis code.

Extraction of trigrams did not process LIKE escape sequences properly,
leading to possible misidentification of trigrams near escapes, resulting
in incorrect index search results.

Fujii Masao

11 years agoDon't get confused if a WAL partial record header has xl_tot_len == 0.
Heikki Linnakangas [Mon, 20 Aug 2012 16:51:42 +0000 (19:51 +0300)]
Don't get confused if a WAL partial record header has xl_tot_len == 0.

If a WAL record header was split across pages, but xl_tot_len was 0, we
would get confused and conclude that we had already read the whole record,
and proceed to CRC check it. That can lead to a crash in RecordIsValid(),
which isn't careful to not read beyond end-of-record, as defined by
xl_tot_len.

Add an explicit sanity check for xl_tot_len <= SizeOfXlogRecord. Also,
make RecordIsValid() more robust by checking in each step that it doesn't
try to access memory beyond end of record, even if a length field in the
record's or a backup block's header is bogus.

Per report and analysis by Tom Lane.

11 years agoFix typo in comment.
Tom Lane [Mon, 20 Aug 2012 02:56:17 +0000 (22:56 -0400)]
Fix typo in comment.

11 years agoRemove obsolete comment.
Tom Lane [Sun, 19 Aug 2012 19:25:43 +0000 (15:25 -0400)]
Remove obsolete comment.

11 years agoAllow OLD and NEW in multi-row VALUES within rules.
Tom Lane [Sun, 19 Aug 2012 18:12:16 +0000 (14:12 -0400)]
Allow OLD and NEW in multi-row VALUES within rules.

Now that we have LATERAL, it's fairly painless to allow this case, which
was left as a TODO in the original multi-row VALUES implementation.

11 years agoMake use of LATERAL in information_schema.sequences view.
Tom Lane [Sat, 18 Aug 2012 20:14:57 +0000 (16:14 -0400)]
Make use of LATERAL in information_schema.sequences view.

It said "XXX: The following could be improved if we had LATERAL" ...
so let's do that.

No catversion bump since either version of the view works fine.

11 years agoAnother round of planner fixes for LATERAL.
Tom Lane [Sat, 18 Aug 2012 18:10:17 +0000 (14:10 -0400)]
Another round of planner fixes for LATERAL.

Formerly, subquery pullup had no need to examine other entries in the range
table, since they could not contain any references to the subquery being
pulled up.  That's no longer true with LATERAL, so now we need to be able
to visit rangetable subexpressions to replace Vars referencing the
pulled-up subquery.  Also, this means that extract_lateral_references must
be unsurprised at encountering lateral PlaceHolderVars, since such might be
created when pulling up a subquery that's underneath an outer join with
respect to the lateral reference.

11 years agoCopy-editing for recent window-functions documentation rewrite.
Tom Lane [Fri, 17 Aug 2012 19:40:35 +0000 (15:40 -0400)]
Copy-editing for recent window-functions documentation rewrite.

Fix grammar, put back some removed information, rearrange for clarity.

11 years agoCheck LIBXML_VERSION instead of testing in configure script.
Tom Lane [Fri, 17 Aug 2012 04:05:26 +0000 (00:05 -0400)]
Check LIBXML_VERSION instead of testing in configure script.

We had put a test for libxml2's xmlStructuredErrorContext variable in
configure, but of course that doesn't work on Windows builds.  The next
best alternative seems to be to test the LIBXML_VERSION symbol provided
by xmlversion.h.

Per report from Talha Bin Rizwan, though this fixes it in a different way
than his proposed patch.

11 years agoUpdate 'int' protocol documentation mention to be "signed", per request
Bruce Momjian [Fri, 17 Aug 2012 02:07:14 +0000 (22:07 -0400)]
Update 'int' protocol documentation mention to be "signed", per request
from Dmitriy Igrishin

11 years agoDelete inaccurate C comment about FSM and adding pages, per Robert Haas.
Bruce Momjian [Thu, 16 Aug 2012 23:02:58 +0000 (19:02 -0400)]
Delete inaccurate C comment about FSM and adding pages, per Robert Haas.

11 years agoAdd URL for include file visualization tool.
Bruce Momjian [Thu, 16 Aug 2012 22:52:08 +0000 (18:52 -0400)]
Add URL for include file visualization tool.

11 years agoDocument that tab completation can interfere with some SQL commands.
Bruce Momjian [Thu, 16 Aug 2012 22:41:38 +0000 (18:41 -0400)]
Document that tab completation can interfere with some SQL commands.

11 years agoAdd warning about pg_ctl restart and the use of relative paths on the command-line.
Bruce Momjian [Thu, 16 Aug 2012 22:15:47 +0000 (18:15 -0400)]
Add warning about pg_ctl restart and the use of relative paths on the command-line.

11 years agoAllow create_index_paths() to consider multiple join bitmapscan paths.
Tom Lane [Thu, 16 Aug 2012 17:03:54 +0000 (13:03 -0400)]
Allow create_index_paths() to consider multiple join bitmapscan paths.

In the initial cut at the "parameterized paths" feature, I'd simplified
create_index_paths() to the point where it would only generate a single
parameterized bitmap path per relation.  Experimentation with an example
supplied by Josh Berkus convinces me that that's not good enough: we really
need to consider a bitmap path for each possible outer relation.  Otherwise
we have regressions relative to pre-9.2 versions, in which the planner
picks a plain indexscan where it should have used a bitmap scan in queries
involving three or more tables.  Indeed, after fixing this, several queries
in the regression tests show improved plans as a result of using bitmap not
plain indexscans.

11 years agoSuppress possibly-uninitialized-variable warning.
Tom Lane [Thu, 16 Aug 2012 16:03:37 +0000 (12:03 -0400)]
Suppress possibly-uninitialized-variable warning.

11 years agoAdd possible alternate tool for pgrminclude, from Peter Geoghegan
Bruce Momjian [Thu, 16 Aug 2012 15:56:00 +0000 (11:56 -0400)]
Add possible alternate tool for pgrminclude, from Peter Geoghegan

11 years agoIn docs, clarify that, without ORDER BY, the window frame is all rows in
Bruce Momjian [Thu, 16 Aug 2012 15:32:22 +0000 (11:32 -0400)]
In docs, clarify that, without ORDER BY, the window frame is all rows in
the partition.

11 years agoRevert: In docs, change a few cases of "not important" to
Bruce Momjian [Thu, 16 Aug 2012 15:26:40 +0000 (11:26 -0400)]
Revert:  In docs, change a few cases of "not important" to
"unimportant".

Per request from Heikki

11 years agoRewrite window function reference section to more clearly explain
Bruce Momjian [Thu, 16 Aug 2012 14:42:42 +0000 (10:42 -0400)]
Rewrite window function reference section to more clearly explain
keywords and concepts, based on suggestions by Florian Pflug.

11 years agoIn docs, change a few cases of "not important" to "unimportant".
Bruce Momjian [Thu, 16 Aug 2012 14:36:33 +0000 (10:36 -0400)]
In docs, change a few cases of "not important" to "unimportant".

11 years agoAdd SP-GiST support for range types.
Heikki Linnakangas [Thu, 16 Aug 2012 09:55:37 +0000 (12:55 +0300)]
Add SP-GiST support for range types.

The implementation is a quad-tree, largely copied from the quad-tree
implementation for points. The lower and upper bound of ranges are the 2d
coordinates, with some extra code to handle empty ranges.

I left out the support for adjacent operator, -|-, from the original patch.
Not because there was necessarily anything wrong with it, but it was more
complicated than the other operators, and I only have limited time for
reviewing. That will follow as a separate patch.

Alexander Korotkov, reviewed by Jeff Davis and me.

11 years agoFix GiST buffering build bug, which caused "failed to re-find parent" errors.
Heikki Linnakangas [Thu, 16 Aug 2012 09:42:11 +0000 (12:42 +0300)]
Fix GiST buffering build bug, which caused "failed to re-find parent" errors.

We use a hash table to track the parents of inner pages, but when inserting
to a leaf page, the caller of gistbufferinginserttuples() must pass a
correct block number of the leaf's parent page. Before gistProcessItup()
descends to a child page, it checks if the downlink needs to be adjusted to
accommodate the new tuple, and updates the downlink if necessary. However,
updating the downlink might require splitting the page, which might move the
downlink to a page to the right. gistProcessItup() doesn't realize that, so
when it descends to the leaf page, it might pass an out-of-date parent block
number as a result. Fix that by returning the block a tuple was inserted to
from gistbufferinginserttuples().

This fixes the bug reported by Zdeněk Jílovec.

11 years agoFix SGML markup; missing tag.
Bruce Momjian [Thu, 16 Aug 2012 03:57:19 +0000 (23:57 -0400)]
Fix SGML markup;  missing tag.

11 years agoDocument that PGDATA has to point to the configuration files, rather
Bruce Momjian [Thu, 16 Aug 2012 02:59:37 +0000 (22:59 -0400)]
Document that PGDATA has to point to the configuration files, rather
than the actual data storage directory.

Per suggestion from Thom Brown

11 years agoDocument that pg_ctl -w allows for the entry of an SSL passphase on
Bruce Momjian [Thu, 16 Aug 2012 00:52:12 +0000 (20:52 -0400)]
Document that pg_ctl -w allows for the entry of an SSL passphase on
startup.

Per report from Thom Brown

11 years agoAdd CREATE FOREIGN TABLE doc reference to CREATE SERVER.
Bruce Momjian [Thu, 16 Aug 2012 00:38:01 +0000 (20:38 -0400)]
Add CREATE FOREIGN TABLE doc reference to CREATE SERVER.

Per suggestion from Ray Stell

11 years agoProperly document that NEW is unassigned in plpgsql for DELETE (not
Bruce Momjian [Thu, 16 Aug 2012 00:29:58 +0000 (20:29 -0400)]
Properly document that NEW is unassigned in plpgsql for DELETE (not
NULL), and OLD is unassigned for INSERT, and NEW/OLD are unassigned (not
NULL) for statement-level triggers.

Per report from Pavel Stehule

11 years agoAdd C comment about new \c parameter requirement for crashed connections.
Bruce Momjian [Wed, 15 Aug 2012 23:17:26 +0000 (19:17 -0400)]
Add C comment about new \c parameter requirement for crashed connections.

11 years agoUpdate C comment to NOTICE to reflect previous commit changing the error
Bruce Momjian [Wed, 15 Aug 2012 23:09:37 +0000 (19:09 -0400)]
Update C comment to NOTICE to reflect previous commit changing the error
level, per report from Tom.

11 years agoIn psql, if the is no connection object, e.g. due to a server crash,
Bruce Momjian [Wed, 15 Aug 2012 23:04:52 +0000 (19:04 -0400)]
In psql, if the is no connection object, e.g. due to a server crash,
require all parameters for \c, rather than using the defaults, which
might be wrong.

11 years agoFix rescan logic in nodeCtescan.
Tom Lane [Wed, 15 Aug 2012 23:01:16 +0000 (19:01 -0400)]
Fix rescan logic in nodeCtescan.

The previous coding essentially assumed that nodes would be rescanned in
the same order they were initialized in; or at least that the "leader" of
a group of CTEscans would be rescanned before any others were required to
execute.  Unfortunately, that isn't even a little bit true.  It's possible
to devise queries in which the leader isn't rescanned until other CTEscans
on the same CTE have run to completion, or even in which the leader never
gets a rescan call at all.

The fix makes the leader specially responsible only for initial creation
and final destruction of the tuplestore; rescan resets are now a
symmetrically shared responsibility.  This means that we might reset the
tuplestore multiple times when restarting a plan subtree containing
multiple CTEscans; but resetting an already-empty tuplestore is cheap
enough that that doesn't seem like a problem.

Per report from Adam Mackler; the new regression test cases are based on
his example query.

Back-patch to 8.4 where CTE scans were introduced.

11 years agoOn second thought, explain why date_trunc("week") on interval values is
Bruce Momjian [Wed, 15 Aug 2012 20:48:05 +0000 (16:48 -0400)]
On second thought, explain why date_trunc("week") on interval values is
not supported in the error message, rather than the docs.

11 years agoDocument why you can't use date_trunc("week") on intervals.
Bruce Momjian [Wed, 15 Aug 2012 20:03:58 +0000 (16:03 -0400)]
Document why you can't use date_trunc("week") on intervals.

11 years agoAdd C comment that '=' is not documented for plpgsql assignment.
Bruce Momjian [Wed, 15 Aug 2012 16:00:56 +0000 (12:00 -0400)]
Add C comment that '=' is not documented for plpgsql assignment.

11 years agoDocument that foreign "version" and "type" values are only useful to
Bruce Momjian [Wed, 15 Aug 2012 15:47:02 +0000 (11:47 -0400)]
Document that foreign "version" and "type" values are only useful to
certain foreign data wrappers.

11 years agoDisallow extensions from owning the schema they are assigned to.
Tom Lane [Wed, 15 Aug 2012 15:26:55 +0000 (11:26 -0400)]
Disallow extensions from owning the schema they are assigned to.

This situation creates a dependency loop that confuses pg_dump and probably
other things.  Moreover, since the mental model is that the extension
"contains" schemas it owns, but "is contained in" its extschema (even
though neither is strictly true), having both true at once is confusing for
people too.  So prevent the situation from being set up.

Reported and patched by Thom Brown.  Back-patch to 9.1 where extensions
were added.

11 years agoProperly escape usernames in initdb, so names with single-quotes are
Bruce Momjian [Wed, 15 Aug 2012 15:23:04 +0000 (11:23 -0400)]
Properly escape usernames in initdb, so names with single-quotes are
supported.  Also add assert to catch future breakage.

Also, improve documentation that "double"-quotes must be used in
pg_hba.conf (not single quotes).

11 years agoResurrect the "last ditch" code path in join_search_one_level().
Tom Lane [Wed, 15 Aug 2012 04:07:15 +0000 (00:07 -0400)]
Resurrect the "last ditch" code path in join_search_one_level().

This essentially reverts commit e54b10a62db2991235fe800c629baef4531a6d67,
in which I'd decided that the "last ditch" join logic was useless.  The
folly of that is now exposed by a report from Pavel Stehule: although the
function should always find at least one join in a self-contained join
problem, it can still fail to do so in a sub-problem created by artificial
from_collapse_limit or join_collapse_limit constraints.  Adjust the
comments to describe this, and simplify the code a bit to match the new
coding of the earlier loop in the function.

I'm not terribly happy about this: I still subscribe to the opinion stated
in the previous commit message that the "last ditch" code can obscure logic
bugs elsewhere.  But the alternative seems to be to complicate the earlier
tests for does-this-relation-have-a-join-clause to the point where they can
tell whether the join clauses link outside the current join sub-problem.
And that looks messy, slow, and possibly a source of bugs in itself.
In any case, now is not the time to be inserting experimental code into
9.2, so let's just go back to the time-tested solution.

11 years agoAdd more limited large object trigger example.
Bruce Momjian [Wed, 15 Aug 2012 03:25:20 +0000 (23:25 -0400)]
Add more limited large object trigger example.

11 years agoAdd doc example of restricting large object trigger firing to only
Bruce Momjian [Wed, 15 Aug 2012 03:21:13 +0000 (23:21 -0400)]
Add doc example of restricting large object trigger firing to only
updates of the column of interest.

11 years agoUpdate release notes for 9.1.5, 9.0.9, 8.4.13, 8.3.20.
Tom Lane [Tue, 14 Aug 2012 22:24:00 +0000 (18:24 -0400)]
Update release notes for 9.1.5, 9.0.9, 8.4.13, 8.3.20.

11 years agoPrevent access to external files/URLs via contrib/xml2's xslt_process().
Tom Lane [Tue, 14 Aug 2012 22:28:29 +0000 (18:28 -0400)]
Prevent access to external files/URLs via contrib/xml2's xslt_process().

libxslt offers the ability to read and write both files and URLs through
stylesheet commands, thus allowing unprivileged database users to both read
and write data with the privileges of the database server.  Disable that
through proper use of libxslt's security options.

Also, remove xslt_process()'s ability to fetch documents and stylesheets
from external files/URLs.  While this was a documented "feature", it was
long regarded as a terrible idea.  The fix for CVE-2012-3489 broke that
capability, and rather than expend effort on trying to fix it, we're just
going to summarily remove it.

While the ability to write as well as read makes this security hole
considerably worse than CVE-2012-3489, the problem is mitigated by the fact
that xslt_process() is not available unless contrib/xml2 is installed,
and the longstanding warnings about security risks from that should have
discouraged prudent DBAs from installing it in security-exposed databases.

Reported and fixed by Peter Eisentraut.

Security: CVE-2012-3488

11 years agoPrevent access to external files/URLs via XML entity references.
Tom Lane [Tue, 14 Aug 2012 22:25:29 +0000 (18:25 -0400)]
Prevent access to external files/URLs via XML entity references.

xml_parse() would attempt to fetch external files or URLs as needed to
resolve DTD and entity references in an XML value, thus allowing
unprivileged database users to attempt to fetch data with the privileges
of the database server.  While the external data wouldn't get returned
directly to the user, portions of it could be exposed in error messages
if the data didn't parse as valid XML; and in any case the mere ability
to check existence of a file might be useful to an attacker.

The ideal solution to this would still allow fetching of references that
are listed in the host system's XML catalogs, so that documents can be
validated according to installed DTDs.  However, doing that with the
available libxml2 APIs appears complex and error-prone, so we're not going
to risk it in a security patch that necessarily hasn't gotten wide review.
So this patch merely shuts off all access, causing any external fetch to
silently expand to an empty string.  A future patch may improve this.

In HEAD and 9.2, also suppress warnings about undefined entities, which
would otherwise occur as a result of not loading referenced DTDs.  Previous
branches don't show such warnings anyway, due to different error handling
arrangements.

Credit to Noah Misch for first reporting the problem, and for much work
towards a solution, though this simplistic approach was not his preference.
Also thanks to Daniel Veillard for consultation.

Security: CVE-2012-3489

11 years agoRevert "commit_delay" change; just add comment that we don't have
Bruce Momjian [Tue, 14 Aug 2012 20:26:08 +0000 (16:26 -0400)]
Revert "commit_delay" change; just add comment that we don't have
a microsecond specification.

11 years agoAdd pg_settings units display for "commit_delay" (ms).
Bruce Momjian [Tue, 14 Aug 2012 20:16:45 +0000 (16:16 -0400)]
Add pg_settings units display for "commit_delay" (ms).

Also remove unnecessary units designation in postgresql.conf.sample.

11 years agoIn documentation, change "recommendable" to "recommended", per
Bruce Momjian [Tue, 14 Aug 2012 16:36:35 +0000 (12:36 -0400)]
In documentation, change "recommendable" to "recommended", per
consultation with word definitions.

Backpatch to 9.2.

11 years agoUpdate time zone data files to tzdata release 2012e.
Tom Lane [Tue, 14 Aug 2012 14:54:24 +0000 (10:54 -0400)]
Update time zone data files to tzdata release 2012e.

DST law changes in Morocco; Tokelau has relocated to the other side of
the International Date Line; and apparently Olson had Tokelau's GMT
offset wrong by an hour even before that.

There are also a large number of non-significant changes in this update.
Upstream took the opportunity to remove trailing whitespace, and the
SCCS-style version numbers on the individual files are gone too.

11 years agoAdd runtime checks for number of query parameters passed to libpq functions.
Heikki Linnakangas [Mon, 13 Aug 2012 13:24:18 +0000 (16:24 +0300)]
Add runtime checks for number of query parameters passed to libpq functions.

The maximum number of parameters supported by the FE/BE protocol is 65535,
as it's transmitted as a 16-bit unsigned integer. However, the nParams
arguments to libpq functions are all of type 'int'. We can't change the
signature of libpq functions, but a simple bounds check is in order to make
it more clear what's going wrong if you try to pass more than 65535
parameters.

Per complaint from Jim Vanns.

11 years agoMore fixes for planner's handling of LATERAL.
Tom Lane [Sun, 12 Aug 2012 20:01:26 +0000 (16:01 -0400)]
More fixes for planner's handling of LATERAL.

Re-allow subquery pullup for LATERAL subqueries, except when the subquery
is below an outer join and contains lateral references to relations outside
that outer join.  If we pull up in such a case, we risk introducing lateral
cross-references into outer joins' ON quals, which is something the code is
entirely unprepared to cope with right now; and I'm not sure it'll ever be
worth coping with.

Support lateral refs in VALUES (this seems to be the only additional path
type that needs such support as a consequence of re-allowing subquery
pullup).

Put in a slightly hacky fix for joinpath.c's refusal to consider
parameterized join paths even when there cannot be any unparameterized
ones.  This was causing "could not devise a query plan for the given query"
failures in queries involving more than two FROM items.

Put in an even more hacky fix for distribute_qual_to_rels() being unhappy
with join quals that contain references to rels outside their syntactic
scope; which is to say, disable that test altogether.  Need to think about
how to preserve some sort of debugging cross-check here, while not
expending more cycles than befits a debugging cross-check.

11 years agoFix some issues with LATERAL(SELECT UNION ALL SELECT).
Tom Lane [Sat, 11 Aug 2012 22:42:20 +0000 (18:42 -0400)]
Fix some issues with LATERAL(SELECT UNION ALL SELECT).

The LATERAL marking has to be propagated down to the UNION leaf queries
when we pull them up.  Also, fix the formerly stubbed-off
set_append_rel_pathlist().  It does already have enough smarts to cope with
making a parameterized Append path at need; it just has to not assume that
there *must* be an unparameterized path.

11 years agoAdd link from COPY ref page to psql \copy.
Tom Lane [Sat, 11 Aug 2012 17:51:22 +0000 (13:51 -0400)]
Add link from COPY ref page to psql \copy.

Jeff Janes

11 years agoFix dependencies generated during ALTER TABLE ADD CONSTRAINT USING INDEX.
Tom Lane [Sat, 11 Aug 2012 16:51:24 +0000 (12:51 -0400)]
Fix dependencies generated during ALTER TABLE ADD CONSTRAINT USING INDEX.

This command generated new pg_depend entries linking the index to the
constraint and the constraint to the table, which match the entries made
when a unique or primary key constraint is built de novo.  However, it did
not bother to get rid of the entries linking the index directly to the
table.  We had considered the issue when the ADD CONSTRAINT USING INDEX
patch was written, and concluded that we didn't need to get rid of the
extra entries.  But this is wrong: ALTER COLUMN TYPE wasn't expecting such
redundant dependencies to exist, as reported by Hubert Depesz Lubaczewski.
On reflection it seems rather likely to break other things as well, since
there are many bits of code that crawl pg_depend for one purpose or
another, and most of them are pretty naive about what relationships they're
expecting to find.  Fortunately it's not that hard to get rid of the extra
dependency entries, so let's do that.

Back-patch to 9.1, where ALTER TABLE ADD CONSTRAINT USING INDEX was added.

11 years agoUpdate overlooked comment.
Tom Lane [Fri, 10 Aug 2012 21:36:54 +0000 (17:36 -0400)]
Update overlooked comment.

11 years agoSupport having multiple Unix-domain sockets per postmaster.
Tom Lane [Fri, 10 Aug 2012 21:26:44 +0000 (17:26 -0400)]
Support having multiple Unix-domain sockets per postmaster.

Replace unix_socket_directory with unix_socket_directories, which is a list
of socket directories, and adjust postmaster's code to allow zero or more
Unix-domain sockets to be created.

This is mostly a straightforward change, but since the Unix sockets ought
to be created after the TCP/IP sockets for safety reasons (better chance
of detecting a port number conflict), AddToDataDirLockFile needs to be
fixed to support out-of-order updates of data directory lockfile lines.
That's a change that had been foreseen to be necessary someday anyway.

Honza Horak, reviewed and revised by Tom Lane