]> granicus.if.org Git - postgresql/log
postgresql
11 years agoFix sporadic rebuilds for .pc files
Peter Eisentraut [Sat, 13 Apr 2013 02:45:51 +0000 (22:45 -0400)]
Fix sporadic rebuilds for .pc files

The build of .pc (pkg-config) files depends on all makefiles in use, and
in dependency tracking mode, the previous coding ended up including
/dev/null as a makefile.  Apparently, on some platforms the modification
time of /dev/null changes sporadically, and so the .pc files would end
up being rebuilt every so often.  Fix that by changing the makefile code
to do without using /dev/null.

11 years agoClean up the mess around EXPLAIN and materialized views.
Tom Lane [Fri, 12 Apr 2013 23:25:20 +0000 (19:25 -0400)]
Clean up the mess around EXPLAIN and materialized views.

Revert the matview-related changes in explain.c's API, as per recent
complaint from Robert Haas.  The reason for these appears to have been
principally some ill-considered choices around having intorel_startup do
what ought to be parse-time checking, plus a poor arrangement for passing
it the view parsetree it needs to store into pg_rewrite when creating a
materialized view.  Do the latter by having parse analysis stick a copy
into the IntoClause, instead of doing it at runtime.  (On the whole,
I seriously question the choice to represent CREATE MATERIALIZED VIEW as a
variant of SELECT INTO/CREATE TABLE AS, because that means injecting even
more complexity into what was already a horrid legacy kluge.  However,
I didn't go so far as to rethink that choice ... yet.)

I also moved several error checks into matview parse analysis, and
made the check for external Params in a matview more accurate.

In passing, clean things up a bit more around interpretOidsOption(),
and fix things so that we can use that to force no-oids for views,
sequences, etc, thereby eliminating the need to cons up "oids = false"
options when creating them.

catversion bump due to change in IntoClause.  (I wonder though if we
really need readfuncs/outfuncs support for IntoClause anymore.)

11 years agopgindent: improve error messages
Bruce Momjian [Fri, 12 Apr 2013 19:25:33 +0000 (15:25 -0400)]
pgindent: improve error messages

per suggestion from Gurjeet Singh

11 years agopgindent: fix downloading of BSD indent binary
Bruce Momjian [Fri, 12 Apr 2013 15:42:27 +0000 (11:42 -0400)]
pgindent:  fix downloading of BSD indent binary

Also fix accessing pgentab binary and tar.

Gurjeet Singh

11 years agosepgsql: Enforce db_procedure:{execute} permission.
Robert Haas [Fri, 12 Apr 2013 12:55:56 +0000 (08:55 -0400)]
sepgsql: Enforce db_procedure:{execute} permission.

To do this, we add an additional object access hook type,
OAT_FUNCTION_EXECUTE.

KaiGai Kohei

11 years agoMinor wording corrections for object-access hook stuff.
Robert Haas [Fri, 12 Apr 2013 12:39:38 +0000 (08:39 -0400)]
Minor wording corrections for object-access hook stuff.

KaiGai Kohei

11 years agosepgql: Use getObjectIdentity rather than getObjectDescription.
Robert Haas [Fri, 12 Apr 2013 12:35:55 +0000 (08:35 -0400)]
sepgql: Use getObjectIdentity rather than getObjectDescription.

KaiGai Kohei, based on a suggestion from Álvaro Herrera

11 years agoDocument that git_changelog needs updating for major version stamping.
Bruce Momjian [Thu, 11 Apr 2013 16:27:02 +0000 (12:27 -0400)]
Document that git_changelog needs updating for major version stamping.

11 years agoRemove quotes around SQL statement in error message
Alvaro Herrera [Thu, 11 Apr 2013 15:00:09 +0000 (12:00 -0300)]
Remove quotes around SQL statement in error message

11 years agoFix confusion between ObjectType and ObjectClass
Alvaro Herrera [Thu, 11 Apr 2013 14:59:47 +0000 (11:59 -0300)]
Fix confusion between ObjectType and ObjectClass

Per report by Will Leinweber and Peter Eisentraut

11 years agodoc: Update DTrace information
Peter Eisentraut [Thu, 11 Apr 2013 03:05:13 +0000 (23:05 -0400)]
doc: Update DTrace information

The old web site link no longer worked, and some information was
outdated.

11 years agoUpdate the description for the graphical installers
Magnus Hagander [Wed, 10 Apr 2013 19:37:49 +0000 (21:37 +0200)]
Update the description for the graphical installers

Remove references to "one click", as we're not supposed to call
them that anymore.

11 years agoFix SIGUSR1 handling by unconnected bgworkers
Alvaro Herrera [Wed, 10 Apr 2013 19:01:16 +0000 (16:01 -0300)]
Fix SIGUSR1 handling by unconnected bgworkers

Latch activity was not being detected by non-database-connected workers; the
SIGUSR1 signal handler which is normally in charge of that was set to SIG_IGN.
Create a simple handler to call latch_sigusr1_handler instead.

Robert Haas (bug report and suggested fix)

11 years agoFix SIGHUP handling by unconnected bgworkers
Alvaro Herrera [Wed, 10 Apr 2013 18:59:45 +0000 (15:59 -0300)]
Fix SIGHUP handling by unconnected bgworkers

Add a SignalUnconnectedWorkers() call so that non-database-connected background
workers are also notified when postmaster is SIGHUPped.  Previously, only
database-connected workers were.

Michael Paquier (bug report and fix)

11 years agoMake contrib/pg_trgm also support regex searches with GiST indexes.
Tom Lane [Wed, 10 Apr 2013 17:30:14 +0000 (13:30 -0400)]
Make contrib/pg_trgm also support regex searches with GiST indexes.

This wasn't addressed in the original patch, but it doesn't take very
much additional code to cover the case, so let's get it done.

Since pg_trgm 1.1 hasn't been released yet, I just changed the definition
of what's in it, rather than inventing a 1.2.

11 years agoMake worker_spi sample code more complete
Alvaro Herrera [Wed, 10 Apr 2013 16:29:25 +0000 (13:29 -0300)]
Make worker_spi sample code more complete

Make use of some GUC variables, and add SIGHUP handling to reload
the config file.  Patch submitted by Guillaume Lelarge.

Also, report to pg_stat_activity.  Per report from Marc Cousin, add
setting of statement start time.

11 years agoFix hstore_to_json_loose example in docs.
Andrew Dunstan [Wed, 10 Apr 2013 13:26:46 +0000 (09:26 -0400)]
Fix hstore_to_json_loose example in docs.

Marti Raudsepp.

11 years agoRemove duplicate initialization in XLogReadRecord.
Robert Haas [Wed, 10 Apr 2013 03:58:02 +0000 (23:58 -0400)]
Remove duplicate initialization in XLogReadRecord.

Per a note from Dickson S. Guedes.

11 years agoCreate a distinction between a populated matview and a scannable one.
Kevin Grittner [Tue, 9 Apr 2013 18:02:49 +0000 (13:02 -0500)]
Create a distinction between a populated matview and a scannable one.

The intent was that being populated would, long term, be just one
of the conditions which could affect whether a matview was
scannable; being populated should be necessary but not always
sufficient to scan the relation.  Since only CREATE and REFRESH
currently determine the scannability, names and comments
accidentally conflated these concepts, leading to confusion.

Also add missing locking for the SQL function which allows a
test for scannability, and fix a modularity violatiion.

Per complaints from Tom Lane, although its not clear that these
will satisfy his concerns.  Hopefully this will at least better
frame the discussion.

11 years agoAdjust ExplainOneQuery_hook_type to take a DestReceiver argument.
Robert Haas [Tue, 9 Apr 2013 14:13:38 +0000 (10:13 -0400)]
Adjust ExplainOneQuery_hook_type to take a DestReceiver argument.

The materialized views patch adjusted ExplainOneQuery to take an
additional DestReceiver argument, but failed to add a matching
argument to the definition of ExplainOneQuery_hook.  This is a
problem for users of the hook that want to call ExplainOnePlan.
Fix by adding the missing argument.

11 years agoSupport indexing of regular-expression searches in contrib/pg_trgm.
Tom Lane [Tue, 9 Apr 2013 05:05:55 +0000 (01:05 -0400)]
Support indexing of regular-expression searches in contrib/pg_trgm.

This works by extracting trigrams from the given regular expression,
in generally the same spirit as the previously-existing support for
LIKE searches, though of course the details are far more complicated.

Currently, only GIN indexes are supported.  We might be able to make
it work with GiST indexes later.

The implementation includes adding API functions to backend/regex/
to provide a view of the search NFA created from a regular expression.
These functions are meant to be generic enough to be supportable in
a standalone version of the regex library, should that ever happen.

Alexander Korotkov, reviewed by Heikki Linnakangas and Tom Lane

11 years agoMinor rewording of README comments
Simon Riggs [Mon, 8 Apr 2013 16:20:26 +0000 (17:20 +0100)]
Minor rewording of README comments

11 years agoFix calculation of how many segments to retain for wal_keep_segments.
Heikki Linnakangas [Mon, 8 Apr 2013 13:26:52 +0000 (16:26 +0300)]
Fix calculation of how many segments to retain for wal_keep_segments.

KeepLogSeg function was broken when we switched to use a 64-bit int for the
segment number.

Per report from Jeff Janes.

11 years agoSkip extraneous locking in XLogCheckBuffer().
Simon Riggs [Mon, 8 Apr 2013 08:11:49 +0000 (09:11 +0100)]
Skip extraneous locking in XLogCheckBuffer().
Heikki reported comment was wrong, so fixed
code to match the comment: we only need to
take additional locking precautions when we
have a shared lock on the buffer.

11 years agoAvoid tricky race condition recording XLOG_HINT
Simon Riggs [Mon, 8 Apr 2013 07:52:39 +0000 (08:52 +0100)]
Avoid tricky race condition recording XLOG_HINT
We copy the buffer before inserting an XLOG_HINT to avoid WAL CRC errors
caused by concurrent hint writes to buffer while share locked. To make this work
we refactor RestoreBackupBlock() to allow an XLOG_HINT to avoid the normal
path for backup blocks, which assumes the underlying buffer is exclusive locked.
Resulting code completely changes layout of XLOG_HINT WAL records, but
this isn't even beta code, so this is a low impact change.
In passing, avoid taking WALInsertLock for full page writes on checksummed
hints, remove related cruft from XLogInsert() and improve xlog_desc record for
XLOG_HINT.

Andres Freund

Bug report by Fujii Masao, testing by Jeff Janes and Jaime Casanova,
review by Jeff Davis and Simon Riggs. Applied with changes from review
and some comment editing.

11 years agoREADME comments on checksums on page holes.
Simon Riggs [Mon, 8 Apr 2013 07:42:52 +0000 (08:42 +0100)]
README comments on checksums on page holes.

11 years agoTune BufferGetLSNAtomic() when checksums !enabled
Simon Riggs [Sun, 7 Apr 2013 21:37:39 +0000 (22:37 +0100)]
Tune BufferGetLSNAtomic() when checksums !enabled

From performance analysis by Heikki Linnakangas

11 years agoFix checksums for CLUSTER, VACUUM FULL etc.
Simon Riggs [Sun, 7 Apr 2013 21:16:51 +0000 (22:16 +0100)]
Fix checksums for CLUSTER, VACUUM FULL etc.
In CLUSTER, VACUUM FULL and ALTER TABLE SET TABLESPACE
I erroneously set checksum before log_newpage, which
sets the LSN and invalidates the checksum. So set
checksum immediately *after* log_newpage.

Bug report Fujii Masao, Fix and patch by Jeff Davis

11 years agoGet rid of USE_WIDE_UPPER_LOWER dependency in trigram construction.
Tom Lane [Sun, 7 Apr 2013 18:45:33 +0000 (14:45 -0400)]
Get rid of USE_WIDE_UPPER_LOWER dependency in trigram construction.

contrib/pg_trgm's make_trigrams() was coded to ignore multibyte character
boundaries and just make trigrams from bytes if USE_WIDE_UPPER_LOWER wasn't
defined.  This is a bit odd, since there's no obvious reason why trigram
compaction rules should depend on the presence of towlower() and friends.
What's more, there was an Assert() that would fail if that code path was
fed any multibyte characters.

We need to do something about this since the pending regex-indexing patch
has an assumption that you get just one "trgm" from any three characters.
The best solution seems to be to remove the USE_WIDE_UPPER_LOWER
dependency, which shouldn't really have been there in the first place.
The second loop in make_trigrams() is now just a fast path and not a
potentially incompatible algorithm.

If there is anybody still using Postgres on machines without wcstombs() or
towlower(), and they have non-ASCII data indexed by pg_trgm, they'll need
to REINDEX those indexes after pg_upgrade to 9.3, else searches may fail
incorrectly. It seems likely that there are no such installations, though.

In passing, rename cnt_trigram to compact_trigram, which seems to better
describe its functionality, and improve make_trigrams' test for whether it
has to use the slow path or not (per a suggestion from Alexander Korotkov).

11 years agoIn isolationtester, retry after EINTR return from select(2).
Tom Lane [Sun, 7 Apr 2013 02:28:49 +0000 (22:28 -0400)]
In isolationtester, retry after EINTR return from select(2).

Per report from Jaime Casanova.  Very curious that no one else has seen
this failure ... but the code is clearly wrong as-is.

11 years agosepgsql: Enforce db_schema:search permission.
Robert Haas [Fri, 5 Apr 2013 12:51:31 +0000 (08:51 -0400)]
sepgsql: Enforce db_schema:search permission.

KaiGai Kohei, with comment and doc wordsmithing by me

11 years agoImprove documentation about the relationship of extensions and schemas.
Tom Lane [Fri, 5 Apr 2013 02:37:25 +0000 (22:37 -0400)]
Improve documentation about the relationship of extensions and schemas.

There's been some confusion expressed about this point, so clarify.
Extended version of a patch by David Wheeler.

11 years agodoc: Fix number of columns in table
Peter Eisentraut [Fri, 5 Apr 2013 01:07:05 +0000 (21:07 -0400)]
doc: Fix number of columns in table

11 years agoFix line count in slashUsage().
Tom Lane [Fri, 5 Apr 2013 00:29:46 +0000 (20:29 -0400)]
Fix line count in slashUsage().

Counting newlines shows that quite a few recent patches have neglected
to update the output-lines count given to PageOutput().  Fortunately
it's not terribly critical that this be exact, since we long since
exceeded the height of most people's terminal windows.  Still, maybe
we ought to think of a way to not have to maintain this manually anymore.

11 years agoAdd \watch [SEC] command to psql.
Tom Lane [Thu, 4 Apr 2013 23:56:33 +0000 (19:56 -0400)]
Add \watch [SEC] command to psql.

This allows convenient re-execution of commands.

Will Leinweber, reviewed by Peter Eisentraut, Daniel Farina, and Tom Lane

11 years agoFix off by one error in JSON extract path code.
Andrew Dunstan [Thu, 4 Apr 2013 22:26:52 +0000 (18:26 -0400)]
Fix off by one error in JSON extract path code.

Bug report by David Wheeler, diagnosis assistance from Tom Lane.

11 years agopsql: fix startup crash caused by PSQLRC containing a tilde
Bruce Momjian [Thu, 4 Apr 2013 16:56:21 +0000 (12:56 -0400)]
psql:  fix startup crash caused by PSQLRC containing a tilde

'strdup' the PSQLRC environment variable value before calling a routine
that might free() it.

Backpatch to 9.2, where the bug first appeared.

11 years agoFix crash on compiling a regular expression with more than 32k colors.
Heikki Linnakangas [Thu, 4 Apr 2013 16:04:57 +0000 (19:04 +0300)]
Fix crash on compiling a regular expression with more than 32k colors.

Throw an error instead.

Backpatch to all supported branches.

11 years agoFix a few thinkos in the JSON functions docs.
Andrew Dunstan [Thu, 4 Apr 2013 14:41:29 +0000 (10:41 -0400)]
Fix a few thinkos in the JSON functions docs.

Dickson S. Guedes

11 years agoCalculate # of semaphores correctly with --disable-spinlocks.
Heikki Linnakangas [Thu, 4 Apr 2013 13:31:44 +0000 (16:31 +0300)]
Calculate # of semaphores correctly with --disable-spinlocks.

The old formula didn't take into account that each WAL sender process needs
a spinlock. We had also already exceeded the fixed number of spinlocks
reserved for misc purposes (10). Bump that to 30.

Backpatch to 9.0, where WAL senders were introduced. If I counted correctly,
9.0 had exactly 10 predefined spinlocks, and 9.1 exceeded that, but bump the
limit in 9.0 too because 10 is uncomfortably close to the edge.

11 years agoAvoid updating our PgBackendStatus entry when track_activities is off.
Tom Lane [Wed, 3 Apr 2013 18:13:28 +0000 (14:13 -0400)]
Avoid updating our PgBackendStatus entry when track_activities is off.

The point of turning off track_activities is to avoid this reporting
overhead, but a thinko in commit 4f42b546fd87a80be30c53a0f2c897acb826ad52
caused pgstat_report_activity() to perform half of its updates anyway.
Fix that, and also make sure that we clear all the now-disabled fields
when transitioning to the non-reporting state.

11 years agoFix typo in FDW docs.
Tom Lane [Wed, 3 Apr 2013 14:26:18 +0000 (10:26 -0400)]
Fix typo in FDW docs.

Laurenz Albe

11 years agoMinor robustness improvements for isolationtester.
Tom Lane [Wed, 3 Apr 2013 01:15:37 +0000 (21:15 -0400)]
Minor robustness improvements for isolationtester.

Notice and complain about PQcancel() failures.  Also, don't dump core if
an error PGresult doesn't contain severity and message subfields, as it
might not if it was generated by libpq itself.  (We have a longstanding
TODO item to improve that, but in the meantime isolationtester had better
cope.)

I tripped across the latter item while investigating a trouble report on
buildfarm member spoonbill.  As for the former, there's no evidence that
PQcancel failure is actually involved in spoonbill's problem, but it still
seems like a bad idea to ignore an error return code.

11 years agoUpdate release notes for 9.2.4, 9.1.9, 9.0.13, 8.4.17.
Tom Lane [Mon, 1 Apr 2013 18:11:11 +0000 (14:11 -0400)]
Update release notes for 9.2.4, 9.1.9, 9.0.13, 8.4.17.

Security: CVE-2013-1899, CVE-2013-1901

11 years agoFix insecure parsing of server command-line switches.
Tom Lane [Mon, 1 Apr 2013 18:00:51 +0000 (14:00 -0400)]
Fix insecure parsing of server command-line switches.

An oversight in commit e710b65c1c56ca7b91f662c63d37ff2e72862a94 allowed
database names beginning with "-" to be treated as though they were secure
command-line switches; and this switch processing occurs before client
authentication, so that even an unprivileged remote attacker could exploit
the bug, needing only connectivity to the postmaster's port.  Assorted
exploits for this are possible, some requiring a valid database login,
some not.  The worst known problem is that the "-r" switch can be invoked
to redirect the process's stderr output, so that subsequent error messages
will be appended to any file the server can write.  This can for example be
used to corrupt the server's configuration files, so that it will fail when
next restarted.  Complete destruction of database tables is also possible.

Fix by keeping the database name extracted from a startup packet fully
separate from command-line switches, as had already been done with the
user name field.

The Postgres project thanks Mitsumasa Kondo for discovering this bug,
Kyotaro Horiguchi for drafting the fix, and Noah Misch for recognizing
the full extent of the danger.

Security: CVE-2013-1899

11 years agoMake REPLICATION privilege checks test current user not authenticated user.
Tom Lane [Mon, 1 Apr 2013 17:09:24 +0000 (13:09 -0400)]
Make REPLICATION privilege checks test current user not authenticated user.

The pg_start_backup() and pg_stop_backup() functions checked the privileges
of the initially-authenticated user rather than the current user, which is
wrong.  For example, a user-defined index function could successfully call
these functions when executed by ANALYZE within autovacuum.  This could
allow an attacker with valid but low-privilege database access to interfere
with creation of routine backups.  Reported and fixed by Noah Misch.

Security: CVE-2013-1901

11 years agoRevert "ecpg: Don't link compatlib with libpq"
Peter Eisentraut [Mon, 1 Apr 2013 03:50:51 +0000 (23:50 -0400)]
Revert "ecpg: Don't link compatlib with libpq"

This reverts commit 3780fc679cc428c1f211e1728c4281ca15e9746b.

HP-UX didn't like it.  There would probably be a way to fix that, but
since the net effect of all of this is zero because ecpg ends up using
libpq anyway, it's not worth bothering further.

11 years agoUpdate release notes for changes through today.
Tom Lane [Sun, 31 Mar 2013 22:59:35 +0000 (18:59 -0400)]
Update release notes for changes through today.

11 years agoIgnore extra subquery outputs in set_subquery_size_estimates().
Tom Lane [Sun, 31 Mar 2013 22:32:54 +0000 (18:32 -0400)]
Ignore extra subquery outputs in set_subquery_size_estimates().

In commit 0f61d4dd1b4f95832dcd81c9688dac56fd6b5687, I added code to copy up
column width estimates for each column of a subquery.  That code supposed
that the subquery couldn't have any output columns that didn't correspond
to known columns of the current query level --- which is true when a query
is parsed from scratch, but the assumption fails when planning a view that
depends on another view that's been redefined (adding output columns) since
the upper view was made.  This results in an assertion failure or even a
crash, as per bug #8025 from lindebg.  Remove the Assert and instead skip
the column if its resno is out of the expected range.

11 years agoAdd pkg-config files for libpq and ecpg libraries
Peter Eisentraut [Sun, 31 Mar 2013 20:58:40 +0000 (16:58 -0400)]
Add pkg-config files for libpq and ecpg libraries

This will hopefully be easier to use than pg_config for users who are
already used to the pkg-config interface.  It also works better for
multi-arch installations.

reviewed by Tom Lane

11 years agoecpg: Don't link compatlib with libpq
Peter Eisentraut [Sun, 31 Mar 2013 20:51:00 +0000 (16:51 -0400)]
ecpg: Don't link compatlib with libpq

It doesn't actually use libpq.  But we need to keep libpq in the
CPPFLAGS for building, because compatlib uses ecpglib.h which uses
libpq-fe.h, but we don't need to refer to libpq for linking.

reviewed by Tom Lane

11 years agopg_upgrade: don't copy/link files for invalid indexes
Bruce Momjian [Sun, 31 Mar 2013 02:20:53 +0000 (22:20 -0400)]
pg_upgrade:  don't copy/link files for invalid indexes

Now that pg_dump no longer dumps invalid indexes, per commit
683abc73dff549e94555d4020dae8d02f32ed78b, have pg_upgrade also skip
them.  Previously pg_upgrade threw an error if invalid indexes existed.

Backpatch to 9.2, 9.1, and 9.0 (where pg_upgrade was added to git)

11 years agoImprove code documentation about "magnetic disk" storage manager.
Tom Lane [Sat, 30 Mar 2013 18:23:45 +0000 (14:23 -0400)]
Improve code documentation about "magnetic disk" storage manager.

The modern incarnation of md.c is by no means specific to magnetic disk
technology, but every so often we hear from someone who's misled by the
label.  Try to clarify that it will work for anything that supports
standard filesystem operations.  Per suggestion from Andrew Dunstan.

11 years agoAvoid moving data directory in upgrade testing.
Andrew Dunstan [Sat, 30 Mar 2013 16:44:29 +0000 (12:44 -0400)]
Avoid moving data directory in upgrade testing.

Windows sometimes gets upset if we rename a large directory and then try
to use the old name quickly, as seen in occasional buildfarm failures.
So we avoid that by building the old version in the intended
destination in the first place instead of renaming it, similar to the
change made for the same reason in commit b7f8465c.

11 years agoRemove tab from SGML file.
Bruce Momjian [Sat, 30 Mar 2013 03:19:03 +0000 (23:19 -0400)]
Remove tab from SGML file.

11 years agoecpg: Parallel make fix
Peter Eisentraut [Sat, 30 Mar 2013 01:39:55 +0000 (21:39 -0400)]
ecpg: Parallel make fix

In some parallel make situations, the install-headers target could be
called before the installation directories are created by installdirs,
causing the installation to fail.  Fix that by making install-headers
depend on installdirs.

11 years agoFix page title for JSON Functions and Operators.
Andrew Dunstan [Fri, 29 Mar 2013 20:56:22 +0000 (16:56 -0400)]
Fix page title for JSON Functions and Operators.

11 years agoAdd new JSON processing functions and parser API.
Andrew Dunstan [Fri, 29 Mar 2013 18:12:13 +0000 (14:12 -0400)]
Add new JSON processing functions and parser API.

The JSON parser is converted into a recursive descent parser, and
exposed for use by other modules such as extensions. The API provides
hooks for all the significant parser event such as the beginning and end
of objects and arrays, and providing functions to handle these hooks
allows for fairly simple construction of a wide variety of JSON
processing functions. A set of new basic processing functions and
operators is also added, which use this API, including operations to
extract array elements, object fields, get the length of arrays and the
set of keys of a field, deconstruct an object into a set of key/value
pairs, and create records from JSON objects and arrays of objects.

Catalog version bumped.

Andrew Dunstan, with some documentation assistance from Merlin Moncure.

11 years agoDocument encode(bytea, 'escape')'s behavior correctly.
Tom Lane [Fri, 29 Mar 2013 03:14:54 +0000 (23:14 -0400)]
Document encode(bytea, 'escape')'s behavior correctly.

I changed this in commit fd15dba543247eb1ce879d22632b9fdb4c230831, but
missed the fact that the SGML documentation of the function specified
exactly what it did.  Well, one of the two places where it's specified
documented that --- probably I looked at the other place and thought
nothing needed to be done.  Sync the two places where encode() and
decode() are described.

11 years agoMust check indisready not just indisvalid when dumping from 9.2 server.
Tom Lane [Fri, 29 Mar 2013 02:09:12 +0000 (22:09 -0400)]
Must check indisready not just indisvalid when dumping from 9.2 server.

9.2 uses a kluge representation of "indislive"; we have to account for
that when examining pg_index.  Simplest solution is to check indisready
for 9.0 and 9.1 as well; that's harmless though unnecessary, so it's
not worth making a version distinction for.

Fixes oversight in commit 683abc73dff549e94555d4020dae8d02f32ed78b,
as noted by Andres Freund.

11 years agoDraft release notes for 9.2.4, 9.1.9, 9.0.13, 8.4.17.
Tom Lane [Fri, 29 Mar 2013 01:40:19 +0000 (21:40 -0400)]
Draft release notes for 9.2.4, 9.1.9, 9.0.13, 8.4.17.

Covers commits through today.  Not back-patching into back branches
yet, since this is just for people to review in advance.

11 years agosepgsql: Documentation improvements.
Robert Haas [Thu, 28 Mar 2013 19:55:44 +0000 (15:55 -0400)]
sepgsql: Documentation improvements.

Fixes by me, per griping by Thom Brown.

11 years agoAllow sepgsql labels to depend on object name.
Robert Haas [Thu, 28 Mar 2013 19:38:35 +0000 (15:38 -0400)]
Allow sepgsql labels to depend on object name.

The main change here is to call security_compute_create_name_raw()
rather than security_compute_create_raw().  This ups the minimum
requirement for libselinux from 2.0.99 to 2.1.10, but it looks
like most distributions will have picked that up before 9.3 is out.

KaiGai Kohei

11 years agoUpdate time zone data files to tzdata release 2013b.
Tom Lane [Thu, 28 Mar 2013 19:25:48 +0000 (15:25 -0400)]
Update time zone data files to tzdata release 2013b.

DST law changes in Chile, Haiti, Morocco, Paraguay, some Russian areas.
Historical corrections for numerous places.

11 years agoAvoid "variable might be clobbered by longjmp" warning.
Tom Lane [Thu, 28 Mar 2013 17:19:49 +0000 (13:19 -0400)]
Avoid "variable might be clobbered by longjmp" warning.

On older-model gcc, the original coding of UTILITY_BEGIN_QUERY() can
draw this error because of multiple assignments to _needCleanup.
Rather than mark that variable volatile, we can suppress the warning
by arranging to have just one unconditional assignment before PG_TRY.

11 years agoAdd sql_drop event for event triggers
Alvaro Herrera [Wed, 27 Mar 2013 19:02:10 +0000 (16:02 -0300)]
Add sql_drop event for event triggers

This event takes place just before ddl_command_end, and is fired if and
only if at least one object has been dropped by the command.  (For
instance, DROP TABLE IF EXISTS of a table that does not in fact exist
will not lead to such a trigger firing).  Commands that drop multiple
objects (such as DROP SCHEMA or DROP OWNED BY) will cause a single event
to fire.  Some firings might be surprising, such as
ALTER TABLE DROP COLUMN.

The trigger is fired after the drop has taken place, because that has
been deemed the safest design, to avoid exposing possibly-inconsistent
internal state (system catalogs as well as current transaction) to the
user function code.  This means that careful tracking of object
identification is required during the object removal phase.

Like other currently existing events, there is support for tag
filtering.

To support the new event, add a new pg_event_trigger_dropped_objects()
set-returning function, which returns a set of rows comprising the
objects affected by the command.  This is to be used within the user
function code, and is mostly modelled after the recently introduced
pg_identify_object() function.

Catalog version bumped due to the new function.

Dimitri Fontaine and Álvaro Herrera
Review by Robert Haas, Tom Lane

11 years agoRevoke bc5334d8679c428a709d150666b288171795bd76
Simon Riggs [Thu, 28 Mar 2013 09:18:02 +0000 (09:18 +0000)]
Revoke bc5334d8679c428a709d150666b288171795bd76

11 years agoRevoke 7a5a59d378e052618d6feae64d1d2b4f2ad6f9bc
Simon Riggs [Thu, 28 Mar 2013 09:12:55 +0000 (09:12 +0000)]
Revoke 7a5a59d378e052618d6feae64d1d2b4f2ad6f9bc

11 years agoReset OpenSSL randomness state in each postmaster child process.
Tom Lane [Wed, 27 Mar 2013 22:50:21 +0000 (18:50 -0400)]
Reset OpenSSL randomness state in each postmaster child process.

Previously, if the postmaster initialized OpenSSL's PRNG (which it will do
when ssl=on in postgresql.conf), the same pseudo-random state would be
inherited by each forked child process.  The problem is masked to a
considerable extent if the incoming connection uses SSL encryption, but
when it does not, identical pseudo-random state is made available to
functions like contrib/pgcrypto.  The process's PID does get mixed into any
requested random output, but on most systems that still only results in 32K
or so distinct random sequences available across all Postgres sessions.
This might allow an attacker who has database access to guess the results
of "secure" operations happening in another session.

To fix, forcibly reset the PRNG after fork().  Each child process that has
need for random numbers from OpenSSL's generator will thereby be forced to
go through OpenSSL's normal initialization sequence, which should provide
much greater variability of the sequences.  There are other ways we might
do this that would be slightly cheaper, but this approach seems the most
future-proof against SSL-related code changes.

This has been assigned CVE-2013-1900, but since the issue and the patch
have already been publicized on pgsql-hackers, there's no point in trying
to hide this commit.

Back-patch to all supported branches.

Marko Kreen

11 years agoFix pasto which broke docs build.
Kevin Grittner [Wed, 27 Mar 2013 21:11:46 +0000 (16:11 -0500)]
Fix pasto which broke docs build.

Commit bc5334d8679c428a709d150666b288171795bd76 accidentally
included a second <variablelist> tag for a new list item.

11 years agoFix buffer pin leak in heap update redo routine.
Heikki Linnakangas [Wed, 27 Mar 2013 19:51:27 +0000 (21:51 +0200)]
Fix buffer pin leak in heap update redo routine.

In a heap update, if the old and new tuple were on different pages, and the
new page no longer existed (because it was subsequently truncated away by
vacuum), heap_xlog_update forgot to release the pin on the old buffer. This
bug was introduced by the "Fix multiple problems in WAL replay" patch,
commit 3bbf668de9f1bc172371681e80a4e769b6d014c8 (on master branch).

With full_page_writes=off, this triggered an "incorrect local pin count"
error later in replay, if the old page was vacuumed.

This fixes bug #7969, reported by Yunong Xiao. Backpatch to 9.0, like the
commit that introduced this bug.

11 years agoSet recovery_config_directory for EXEC_BACKEND.
Simon Riggs [Wed, 27 Mar 2013 16:35:38 +0000 (16:35 +0000)]
Set recovery_config_directory for EXEC_BACKEND.
Remove comment questioning whether this is necessary for DataDir.
From buildfarm failures on Windows.

11 years agoMove some pg_dump function around.
Heikki Linnakangas [Wed, 27 Mar 2013 16:10:40 +0000 (18:10 +0200)]
Move some pg_dump function around.

Move functions used only by pg_dump and pg_restore from dumputils.c to a new
file, pg_backup_utils.c. dumputils.c is linked into psql and some programs
in bin/scripts, so it seems good to keep it slim. The parallel functionality
is moved to parallel.c, as is exit_horribly, because the interesting code in
exit_horribly is parallel-related.

This refactoring gets rid of the on_exit_msg_func function pointer. It was
problematic, because a modern gcc version with -Wmissing-format-attribute
complained if it wasn't marked with PF_PRINTF_ATTRIBUTE, but the ancient gcc
version that Tom Lane's old HP-UX box has didn't accept that attribute on a
function pointer, and gave an error. We still use a similar function pointer
trick for getLocalPQBuffer() function, to use a thread-local version of that
in parallel mode on Windows, but that dodges the problem because it doesn't
take printf-like arguments.

11 years agosepgsql: Support for new post-ALTER access hook.
Robert Haas [Wed, 27 Mar 2013 12:10:14 +0000 (08:10 -0400)]
sepgsql: Support for new post-ALTER access hook.

KaiGai Kohei

11 years agoAllow external recovery_config_directory
Simon Riggs [Wed, 27 Mar 2013 11:45:42 +0000 (11:45 +0000)]
Allow external recovery_config_directory
If required, recovery.conf can now be located outside of the data directory.
Server needs read/write permissions on this directory.

11 years agoFix grammatical errors in some new message strings.
Tom Lane [Tue, 26 Mar 2013 21:52:00 +0000 (17:52 -0400)]
Fix grammatical errors in some new message strings.

Daniele Varrazzo

11 years agoIgnore invalid indexes in pg_dump.
Tom Lane [Tue, 26 Mar 2013 21:43:19 +0000 (17:43 -0400)]
Ignore invalid indexes in pg_dump.

Dumping invalid indexes can cause problems at restore time, for example
if the reason the index creation failed was because it tried to enforce
a uniqueness condition not satisfied by the table's data.  Also, if the
index creation is in fact still in progress, it seems reasonable to
consider it to be an uncommitted DDL change, which pg_dump wouldn't be
expected to dump anyway.

Back-patch to all active versions, and teach them to ignore invalid
indexes in servers back to 8.2, where the concept was introduced.

Michael Paquier

11 years agoFix pg_dump against 9.1/9.2 servers.
Heikki Linnakangas [Tue, 26 Mar 2013 13:43:19 +0000 (15:43 +0200)]
Fix pg_dump against 9.1/9.2 servers.

The parallel pg_dump patch forgot to add relpages column to 9.1/9.2 version
of the getTables() query.

Reported by Bernd Helmle.

11 years agoGet rid of obsolete parse_version helper function.
Heikki Linnakangas [Tue, 26 Mar 2013 13:21:57 +0000 (15:21 +0200)]
Get rid of obsolete parse_version helper function.

For getting the server's version in numeric form, use PQserverVersion().
It does the exact same parsing as dumputils.c's parse_version(), and has
been around in libpq for a long time. For the client's version, just use
the PG_VERSION_NUM constant.

11 years agoFix a small logic bug in adjusted parallel restore code.
Andrew Dunstan [Tue, 26 Mar 2013 02:52:28 +0000 (22:52 -0400)]
Fix a small logic bug in adjusted parallel restore code.

11 years agoIn base backup, only include our own tablespace version directory.
Heikki Linnakangas [Mon, 25 Mar 2013 18:19:22 +0000 (20:19 +0200)]
In base backup, only include our own tablespace version directory.

If you have clusters of different versions pointing to the same tablespace
location, we would incorrectly include all the data belonging to the other
versions, too.

Fixes bug #7986, reported by Sergey Burladyan.

11 years agoMake pg_basebackup work with pre-9.3 servers, and add server version check.
Heikki Linnakangas [Fri, 22 Mar 2013 11:02:59 +0000 (13:02 +0200)]
Make pg_basebackup work with pre-9.3 servers, and add server version check.

A new 'starttli' field was added to the response of BASE_BACKUP command.
Make pg_basebackup tolerate the case that it's missing, so that it still
works with older servers.

Add an explicit check for the server version, so that you get a nicer error
message if you try to use it with a pre-9.1 server.

The streaming protocol message format changed in 9.3, so -X stream still won't
work with pre-9.3 servers. I added a version check to ReceiveXLogStream()
earlier, but write that slightly differently, so that in 9.4, it will still
work with a 9.3 server. (In 9.4, the error message needs to be adjusted to
"9.3 or above", though). Also, if the version check fails, don't retry.

11 years agoAdd PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.
Heikki Linnakangas [Mon, 25 Mar 2013 08:06:03 +0000 (10:06 +0200)]
Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.

Per warning from -Wmissing-format-attribute.

11 years agoAdd missing #include.
Heikki Linnakangas [Mon, 25 Mar 2013 07:55:43 +0000 (09:55 +0200)]
Add missing #include.

time(2) requires time.h.

11 years agoFix some unportable constructs in parallel pg_dump code.
Tom Lane [Sun, 24 Mar 2013 19:35:37 +0000 (15:35 -0400)]
Fix some unportable constructs in parallel pg_dump code.

Didn't compile on semi-obsolete gcc, and probably not on not-gcc-at-all
either.

11 years agoAdd parallel pg_dump option.
Andrew Dunstan [Sun, 24 Mar 2013 15:27:20 +0000 (11:27 -0400)]
Add parallel pg_dump option.

New infrastructure is added which creates a set number of workers
(threads on Windows, forked processes on Unix). Jobs are then
handed out to these workers by the master process as needed.
pg_restore is adjusted to use this new infrastructure in place of the
old setup which created a new worker for each step on the fly. Parallel
dumps acquire a snapshot clone in order to stay consistent, if
available.

The parallel option is selected by the -j / --jobs command line
parameter of pg_dump.

Joachim Wieland, lightly editorialized by Andrew Dunstan.

11 years agoUpdate time zone abbreviation lists for changes missed since 2006.
Tom Lane [Sat, 23 Mar 2013 23:16:36 +0000 (19:16 -0400)]
Update time zone abbreviation lists for changes missed since 2006.

Most (all?) of Russia has moved to what's effectively year-round daylight
savings time, so that the "standard" zone names now mean an hour later
than they used to.  Update that, notably changing MSK as per recent
complaint from Sergey Konoplev, but also CHOT, GET, IRKT, KGT, KRAT,
MAGT, NOVT, OMST, VLAT, YAKT, YEKT.  The corresponding DST abbreviations
are presumably now obsolete, but I left them in place with their old
definitions, just to reduce any possible breakage from this change.

Also add VOLT (Europe/Volgograd), which for some reason we never had
before, as well as MIST (Antarctica/Macquarie), and fix obsolete
definitions of MAWT, TKT, and WST.

11 years agoSemi-automatically detect changes in timezone abbreviations.
Tom Lane [Sat, 23 Mar 2013 22:47:22 +0000 (18:47 -0400)]
Semi-automatically detect changes in timezone abbreviations.

Add an option to zic.c to dump out all non-obsolete timezone abbreviations
defined in the Olson database.  Comparing this list to its previous state
will clue us in when something happens that we may need to account for in
the tznames/ time zone abbreviation lists.  The README file's previous
exhortation to "just grep for differences" was completely useless advice,
in my now-considerable experience; but maybe this will be a bit more
useful.  As a starting point I built the same list from the tzdata files
as they existed in 2006, which is committed here as known_abbrevs.txt.
Comparison indeed turned up quite a few changes we had neglected to account
for, which I will commit separately.

11 years agoAvoid renaming data directory during MSVC upgrade testing.
Andrew Dunstan [Sat, 23 Mar 2013 20:26:06 +0000 (16:26 -0400)]
Avoid renaming data directory during MSVC upgrade testing.

This appears to cause some intermittent file system problems
on Windows 8. Instead, set up the old data directory in its
intended final location to start with.

11 years agoDon't put <indexterm> before <term> in <varlistentry> items.
Tom Lane [Sat, 23 Mar 2013 18:06:33 +0000 (14:06 -0400)]
Don't put <indexterm> before <term> in <varlistentry> items.

Doing that results in a broken index entry in PDF output.  We had only
a few like that, which is probably why nobody noticed before.
Standardize on putting the <term> first.

Josh Kupershmidt

11 years agoDocument cross-version compatibility issues for contrib/postgres_fdw.
Tom Lane [Fri, 22 Mar 2013 21:22:31 +0000 (17:22 -0400)]
Document cross-version compatibility issues for contrib/postgres_fdw.

One of the use-cases for postgres_fdw is extracting data from older PG
servers, so cross-version compatibility is important.  Document what we
can do here, and further annotate some of the coding choices that create
compatibility constraints.  In passing, remove one unnecessary
incompatibility with old servers, namely assuming that we didn't need to
quote the timezone name 'UTC'.

11 years agoFix contrib/dblink to handle inconsistent DateStyle/IntervalStyle safely.
Tom Lane [Fri, 22 Mar 2013 19:22:15 +0000 (15:22 -0400)]
Fix contrib/dblink to handle inconsistent DateStyle/IntervalStyle safely.

If the remote database's settings of these GUCs are different from ours,
ambiguous datetime values may be read incorrectly.  To fix, temporarily
adopt the remote server's settings while we ingest a query result.

This is not a complete fix, since it doesn't do anything about ambiguous
values in commands sent to the remote server; but there seems little we
can do about that end of it given dblink's entirely textual API for
transmitted commands.

Back-patch to 9.2.  The hazard exists in all versions, but this patch
would need more work to apply before 9.2.  Given the lack of field
complaints about this issue, it doesn't seem worth the effort at present.

Daniel Farina and Tom Lane

11 years agoFix problems with incomplete attempt to prohibit OIDS with MVs.
Kevin Grittner [Fri, 22 Mar 2013 18:27:34 +0000 (13:27 -0500)]
Fix problems with incomplete attempt to prohibit OIDS with MVs.

Problem with assertion failure in restoring from pg_dump output
reported by Joachim Wieland.

Review and suggestions by Tom Lane and Robert Haas.

11 years agoSuppress uninitialized-variable warning in new checksum code.
Tom Lane [Fri, 22 Mar 2013 16:27:50 +0000 (12:27 -0400)]
Suppress uninitialized-variable warning in new checksum code.

Some compilers understand that this coding is safe, and some don't.

11 years agoUpdate commit_delay documentation.
Tom Lane [Fri, 22 Mar 2013 15:39:15 +0000 (11:39 -0400)]
Update commit_delay documentation.

Commit 13fe298ca06f5390df5edf073cf401f9f0b67458 changed this GUC to be
PGC_SUSET, but neglected to update the documentation to match.

While at it, edit and rearrange the text a little for clarity.

11 years agoAdd new README file for pages/checksums
Simon Riggs [Fri, 22 Mar 2013 14:21:58 +0000 (14:21 +0000)]
Add new README file for pages/checksums

11 years agoAllow I/O reliability checks using 16-bit checksums
Simon Riggs [Fri, 22 Mar 2013 13:54:07 +0000 (13:54 +0000)]
Allow I/O reliability checks using 16-bit checksums

Checksums are set immediately prior to flush out of shared buffers
and checked when pages are read in again. Hint bit setting will
require full page write when block is dirtied, which causes various
infrastructure changes. Extensive comments, docs and README.

WARNING message thrown if checksum fails on non-all zeroes page;
ERROR thrown but can be disabled with ignore_checksum_failure = on.

Feature enabled by an initdb option, since transition from option off
to option on is long and complex and has not yet been implemented.
Default is not to use checksums.

Checksum used is WAL CRC-32 truncated to 16-bits.

Simon Riggs, Jeff Davis, Greg Smith
Wide input and assistance from many community members. Thank you.

11 years agoSilence compiler warnings about unused values.
Andrew Dunstan [Fri, 22 Mar 2013 13:14:16 +0000 (09:14 -0400)]
Silence compiler warnings about unused values.

Per gripe from Kevin Grittner.

11 years agoChange commit_delay to be SUSET for 9.3+
Simon Riggs [Fri, 22 Mar 2013 12:01:16 +0000 (12:01 +0000)]
Change commit_delay to be SUSET for 9.3+
Prior to 9.3 the commit_delay affected only the current user,
whereas now only the group leader waits while holding the
WALWriteLock. Deliberate or accidental settings to a poor
value could seriously degrade performance for all users.
Privileges may be delegated by SECURITY DEFINER functions
for anyone that needs per-user settings in real situations.
Request for change from Peter Geoghegan

11 years agoAvoid retrieving dummy NULL columns in postgres_fdw.
Tom Lane [Fri, 22 Mar 2013 04:31:11 +0000 (00:31 -0400)]
Avoid retrieving dummy NULL columns in postgres_fdw.

This should provide some marginal overall savings, since it surely takes
many more cycles for the remote server to deal with the NULL columns than
it takes for postgres_fdw not to emit them.  But really the reason is to
keep the emitted queries from looking quite so silly ...