]> granicus.if.org Git - postgresql/log
postgresql
12 years agoInherit max_safe_fds to child processes in EXEC_BACKEND mode.
Heikki Linnakangas [Thu, 29 Mar 2012 05:19:11 +0000 (08:19 +0300)]
Inherit max_safe_fds to child processes in EXEC_BACKEND mode.

Postmaster sets max_safe_fds by testing how many open file descriptors it
can open, and that is normally inherited by all child processes at fork().
Not so on EXEC_BACKEND, ie. Windows, however. Because of that, we
effectively ignored max_files_per_process on Windows, and always assumed
a conservative default of 32 simultaneous open files. That could have an
impact on performance, if you need to access a lot of different files
in a query. After this patch, the value is passed to child processes by
save/restore_backend_variables() among many other global variables.

It has been like this forever, but given the lack of complaints about it,
I'm not backpatching this.

12 years agoRemove now redundant pgpipe code.
Andrew Dunstan [Thu, 29 Mar 2012 03:24:07 +0000 (23:24 -0400)]
Remove now redundant pgpipe code.

12 years agoImprove contrib/pg_stat_statements to lump "similar" queries together.
Tom Lane [Thu, 29 Mar 2012 01:00:31 +0000 (21:00 -0400)]
Improve contrib/pg_stat_statements to lump "similar" queries together.

pg_stat_statements now hashes selected fields of the analyzed parse tree
to assign a "fingerprint" to each query, and groups all queries with the
same fingerprint into a single entry in the pg_stat_statements view.
In practice it is expected that queries with the same fingerprint will be
equivalent except for values of literal constants.  To make the display
more useful, such constants are replaced by "?" in the displayed query
strings.

This mechanism currently supports only optimizable queries (SELECT,
INSERT, UPDATE, DELETE).  Utility commands are still matched on the
basis of their literal query strings.

There remain some open questions about how to deal with utility statements
that contain optimizable queries (such as EXPLAIN and SELECT INTO) and how
to deal with expiring speculative hashtable entries that are made to save
the normalized form of a query string.  However, fixing these issues should
require only localized changes, and since there are other open patches
involving contrib/pg_stat_statements, it seems best to go ahead and commit
what we've got.

Peter Geoghegan, reviewed by Daniel Farina

12 years agoRun maintainer-check on all PO files, not only configured ones
Peter Eisentraut [Wed, 28 Mar 2012 18:06:45 +0000 (21:06 +0300)]
Run maintainer-check on all PO files, not only configured ones

The intent is to allow configure --enable-nls=xx for installation
speed and size, but have maintainer-check check all source files
regardless.

12 years agoTweak markup to avoid extra whitespace in man pages
Peter Eisentraut [Wed, 28 Mar 2012 17:37:19 +0000 (20:37 +0300)]
Tweak markup to avoid extra whitespace in man pages

12 years agoAttempt to unbreak pg_test_timing on Windows.
Robert Haas [Wed, 28 Mar 2012 16:22:57 +0000 (12:22 -0400)]
Attempt to unbreak pg_test_timing on Windows.

Per buildfarm, and Álvaro Herrera.

12 years agopg_basebackup: Error handling fixes.
Robert Haas [Wed, 28 Mar 2012 16:19:22 +0000 (12:19 -0400)]
pg_basebackup: Error handling fixes.

Thomas Ogrisegg and Fujii Masao

12 years agopg_basebackup: Error message improvements.
Robert Haas [Wed, 28 Mar 2012 12:43:35 +0000 (08:43 -0400)]
pg_basebackup: Error message improvements.

Fujii Masao

12 years agoDoc fix for pg_test_timing.
Robert Haas [Wed, 28 Mar 2012 12:16:19 +0000 (08:16 -0400)]
Doc fix for pg_test_timing.

Fujii Masao

12 years agopg_test_timing utility, to measure clock monotonicity and timing cost.
Robert Haas [Tue, 27 Mar 2012 20:14:00 +0000 (16:14 -0400)]
pg_test_timing utility, to measure clock monotonicity and timing cost.

Ants Aasma, Greg Smith

12 years agoExpose track_iotiming information via pg_stat_statements.
Robert Haas [Tue, 27 Mar 2012 19:17:22 +0000 (15:17 -0400)]
Expose track_iotiming information via pg_stat_statements.

Ants Aasma, reviewed by Greg Smith, with very minor tweaks by me.

12 years agoBend parse location rules for the convenience of pg_stat_statements.
Tom Lane [Tue, 27 Mar 2012 19:17:00 +0000 (15:17 -0400)]
Bend parse location rules for the convenience of pg_stat_statements.

Generally, the parse location assigned to a multiple-token construct is
the location of its leftmost token.  This commit breaks that rule for
the syntaxes TYPENAME 'LITERAL' and CAST(CONSTANT AS TYPENAME) --- the
resulting Const will have the location of the literal string, not the
typename or CAST keyword.  The cases where this matters are pretty thin on
the ground (no error messages in the regression tests change, for example),
and it's unlikely that any user would be confused anyway by an error cursor
pointing at the literal.  But still it's less than consistent.  The reason
for changing it is that contrib/pg_stat_statements wants to know the parse
location of the original literal, and it was agreed that this is the least
unpleasant way to preserve that information through parse analysis.

Peter Geoghegan

12 years agoAdd some infrastructure for contrib/pg_stat_statements.
Tom Lane [Tue, 27 Mar 2012 19:14:13 +0000 (15:14 -0400)]
Add some infrastructure for contrib/pg_stat_statements.

Add a queryId field to Query and PlannedStmt.  This is not used by the
core backend, except for being copied around at appropriate times.
It's meant to allow plug-ins to track a particular query forward from
parse analysis to execution.

The queryId is intentionally not dumped into stored rules (and hence this
commit doesn't bump catversion).  You could argue that choice either way,
but it seems better that stored rule strings not have any dependency
on plug-ins that might or might not be present.

Also, add a post_parse_analyze_hook that gets invoked at the end of
parse analysis (but only for top-level analysis of complete queries,
not cases such as analyzing a domain's default-value expression).
This is mainly meant to be used to compute and assign a queryId,
but it could have other applications.

Peter Geoghegan

12 years agoNew GUC, track_iotiming, to track I/O timings.
Robert Haas [Tue, 27 Mar 2012 18:52:37 +0000 (14:52 -0400)]
New GUC, track_iotiming, to track I/O timings.

Currently, the only way to see the numbers this gathers is via
EXPLAIN (ANALYZE, BUFFERS), but the plan is to add visibility through
the stats collector and pg_stat_statements in subsequent patches.

Ants Aasma, reviewed by Greg Smith, with some further changes by me.

12 years agoSilence compiler warning about uninitialized variable.
Tom Lane [Tue, 27 Mar 2012 18:47:23 +0000 (14:47 -0400)]
Silence compiler warning about uninitialized variable.

12 years agopg_dump: Small message adjustment for consistency
Peter Eisentraut [Tue, 27 Mar 2012 16:52:39 +0000 (19:52 +0300)]
pg_dump: Small message adjustment for consistency

12 years agoImprove PL/Python database access function documentation
Peter Eisentraut [Mon, 26 Mar 2012 18:15:16 +0000 (21:15 +0300)]
Improve PL/Python database access function documentation

Organize the function descriptions as a list instead of running text,
for easier access.

12 years agoRemove dead assignment
Peter Eisentraut [Mon, 26 Mar 2012 18:03:10 +0000 (21:03 +0300)]
Remove dead assignment

found by Coverity

12 years agoCode cleanup for heap_freeze_tuple.
Robert Haas [Mon, 26 Mar 2012 15:03:06 +0000 (11:03 -0400)]
Code cleanup for heap_freeze_tuple.

It used to be case that lazy vacuum could call this function with only
a shared lock on the buffer, but neither lazy vacuum nor any other
code path does that any more.  Simplify the code accordingly and clean
up some related, obsolete comments.

12 years agoFix COPY FROM for null marker strings that correspond to invalid encoding.
Tom Lane [Mon, 26 Mar 2012 03:17:22 +0000 (23:17 -0400)]
Fix COPY FROM for null marker strings that correspond to invalid encoding.

The COPY documentation says "COPY FROM matches the input against the null
string before removing backslashes".  It is therefore reasonable to presume
that null markers like E'\\0' will work ... and they did, until someone put
the tests in the wrong order during microoptimization-driven rewrites.
Since then, we've been failing if the null marker is something that would
de-escape to an invalidly-encoded string.  Since null markers generally
need to be something that can't appear in the data, this represents a
nontrivial loss of functionality; surprising nobody noticed it earlier.

Per report from Jeff Davis.  Backpatch to 8.4 where this got broken.

12 years agoReplace empty locale name with implied value in CREATE DATABASE and initdb.
Tom Lane [Mon, 26 Mar 2012 01:47:22 +0000 (21:47 -0400)]
Replace empty locale name with implied value in CREATE DATABASE and initdb.

setlocale() accepts locale name "" as meaning "the locale specified by the
process's environment variables".  Historically we've accepted that for
Postgres' locale settings, too.  However, it's fairly unsafe to store an
empty string in a new database's pg_database.datcollate or datctype fields,
because then the interpretation could vary across postmaster restarts,
possibly resulting in index corruption and other unpleasantness.

Instead, we should expand "" to whatever it means at the moment of calling
CREATE DATABASE, which we can do by saving the value returned by
setlocale().

For consistency, make initdb set up the initial lc_xxx parameter values the
same way.  initdb was already doing the right thing for empty locale names,
but it did not replace non-empty names with setlocale results.  On a
platform where setlocale chooses to canonicalize the spellings of locale
names, this would result in annoying inconsistency.  (It seems that popular
implementations of setlocale don't do such canonicalization, which is a
pity, but the POSIX spec certainly allows it to be done.)  The same risk
of inconsistency leads me to not venture back-patching this, although it
could certainly be seen as a longstanding bug.

Per report from Jeff Davis, though this is not his proposed patch.

12 years agoFix planner's handling of outer PlaceHolderVars within subqueries.
Tom Lane [Sat, 24 Mar 2012 20:21:39 +0000 (16:21 -0400)]
Fix planner's handling of outer PlaceHolderVars within subqueries.

For some reason, in the original coding of the PlaceHolderVar mechanism
I had supposed that PlaceHolderVars couldn't propagate into subqueries.
That is of course entirely possible.  When it happens, we need to treat
an outer-level PlaceHolderVar much like an outer Var or Aggref, that is
SS_replace_correlation_vars() needs to replace the PlaceHolderVar with
a Param, and then when building the finished SubPlan we have to provide
the PlaceHolderVar expression as an actual parameter for the SubPlan.
The handling of the contained expression is a bit delicate but it can be
treated exactly like an Aggref's expression.

In addition to the missing logic in subselect.c, prepjointree.c was failing
to search subqueries for PlaceHolderVars that need their relids adjusted
during subquery pullup.  It looks like everyplace else that touches
PlaceHolderVars got it right, though.

Per report from Mark Murawski.  In 9.1 and HEAD, queries affected by this
oversight would fail with "ERROR: Upper-level PlaceHolderVar found where
not expected".  But in 9.0 and 8.4, you'd silently get possibly-wrong
answers, since the value transmitted into the subquery wouldn't go to null
when it should.

12 years agoCast some printf arguments to avoid possibly-nonportable behavior.
Tom Lane [Sat, 24 Mar 2012 00:18:04 +0000 (20:18 -0400)]
Cast some printf arguments to avoid possibly-nonportable behavior.

Per compiler warnings on buildfarm member black_firefly.

12 years agoRefactor simplify_function et al to centralize argument simplification.
Tom Lane [Fri, 23 Mar 2012 23:15:58 +0000 (19:15 -0400)]
Refactor simplify_function et al to centralize argument simplification.

We were doing the recursive simplification of function/operator arguments
in half a dozen different places, with rather baroque logic to ensure it
didn't get done multiple times on some arguments.  This patch improves that
by postponing argument simplification until after we've dealt with named
parameters and added any needed default expressions.

Marti Raudsepp, somewhat hacked on by me

12 years agoCode review for protransform patches.
Tom Lane [Fri, 23 Mar 2012 21:29:57 +0000 (17:29 -0400)]
Code review for protransform patches.

Fix loss of previous expression-simplification work when a transform
function fires: we must not simply revert to untransformed input tree.
Instead build a dummy FuncExpr node to pass to the transform function.
This has the additional advantage of providing a simpler, more uniform
API for transform functions.

Move documentation to a somewhat less buried spot, relocate some
poorly-placed code, be more wary of null constants and invalid typmod
values, add an opr_sanity check on protransform function signatures,
and some other minor cosmetic adjustments.

Note: although this patch touches pg_proc.h, no need for catversion
bump, because the changes are cosmetic and don't actually change the
intended catalog contents.

12 years agoClarify that PQconninfoParse returns an array with all legal options.
Robert Haas [Fri, 23 Mar 2012 02:09:20 +0000 (22:09 -0400)]
Clarify that PQconninfoParse returns an array with all legal options.

Per discussion with Dmitriy Igrishin and Tom Lane.

12 years agoDoc clarifications regarding use of varlena.
Robert Haas [Thu, 22 Mar 2012 19:45:42 +0000 (15:45 -0400)]
Doc clarifications regarding use of varlena.

Jay Levitt, reviewed by Tom Lane.

12 years agoUpdate docs on numeric storage requirements.
Robert Haas [Thu, 22 Mar 2012 19:40:27 +0000 (15:40 -0400)]
Update docs on numeric storage requirements.

Since 9.1, the minimum overhead is three bytes, not five.

Fujii Masao

12 years agoFix GET DIAGNOSTICS for case of assignment to function's first variable.
Tom Lane [Thu, 22 Mar 2012 18:13:17 +0000 (14:13 -0400)]
Fix GET DIAGNOSTICS for case of assignment to function's first variable.

An incorrect and entirely unnecessary "safety check" in exec_stmt_getdiag()
caused the code to treat an assignment to a variable with dno zero as a
no-op.  Unfortunately, that's a perfectly valid dno.  This has been broken
since GET DIAGNOSTICS was invented.  It's not terribly surprising that the
bug went unnoticed for so long, since in most cases you probably wouldn't
use the function's first-created variable (normally its first parameter)
as a GET DIAGNOSTICS target.  Nonetheless, it's broken.  Per bug #6551
from Adam Buraczewski.

12 years agoRefactor to eliminate duplicate copies of conninfo default-finding code.
Tom Lane [Thu, 22 Mar 2012 16:08:34 +0000 (12:08 -0400)]
Refactor to eliminate duplicate copies of conninfo default-finding code.

Alex Shulgin, lightly edited by me

12 years agoIf a role has a password expiration date, show that in psql's \du output.
Tom Lane [Thu, 22 Mar 2012 06:08:25 +0000 (02:08 -0400)]
If a role has a password expiration date, show that in psql's \du output.

Per a suggestion from Euler Taveira, it seems like a good idea to include
this information in \du (and \dg) output.  This costs nothing for people
who are not using the VALID UNTIL feature, while for those who are, it's
rather critical information.

Fabrízio de Royes Mello

12 years agoFix configure's search for collateindex.pl.
Tom Lane [Thu, 22 Mar 2012 04:46:03 +0000 (00:46 -0400)]
Fix configure's search for collateindex.pl.

PGAC_PATH_COLLATEINDEX supposed that it could use AC_PATH_PROGS to search
for collateindex.pl, but that macro will only accept files that are marked
executable, and at least some DocBook installations don't mark the script
executable (a case the docs Makefile was already prepared for).  Accept the
script if it's present and readable in $DOCBOOKSTYLE/bin, and otherwise
search the PATH as before.

Having fixed that up, we don't need the fallback case that was in the docs
Makefile, and instead can throw an understandable error if configure didn't
find the script.  Per recent trouble report from John Lumby.

12 years agoClean up compiler warnings from unused variables with asserts disabled
Peter Eisentraut [Wed, 21 Mar 2012 21:30:14 +0000 (23:30 +0200)]
Clean up compiler warnings from unused variables with asserts disabled

For those variables only used when asserts are enabled, use a new
macro PG_USED_FOR_ASSERTS_ONLY, which expands to
__attribute__((unused)) when asserts are not enabled.

12 years agoAdd installing entab to pgindent instructions
Peter Eisentraut [Wed, 21 Mar 2012 19:27:30 +0000 (21:27 +0200)]
Add installing entab to pgindent instructions

And minor other pgindent documentation tweaks.

12 years agoDoc updates for index-only scans.
Robert Haas [Wed, 21 Mar 2012 18:51:11 +0000 (14:51 -0400)]
Doc updates for index-only scans.

Document that routine vacuuming is now also important for the purpose
of index-only scans; and mention in the section that describes the
visibility map that it is used to implement index-only scans.

Marti Raudsepp, with some changes by me.

12 years agoAllow new relmapper entries when allow_system_table_mods is true.
Tom Lane [Wed, 21 Mar 2012 18:09:39 +0000 (14:09 -0400)]
Allow new relmapper entries when allow_system_table_mods is true.

This restores the pre-9.0 situation that it's possible to add new indexes
on pg_class and other mapped-but-not-shared catalogs, so long as you broke
the glass and flipped the big red Dont-Touch-Me switch.  As before, there
are a lot of gotchas, and you'd have to be pretty desperate to try this
on a production database; but there doesn't seem to be a reason for
relmapper.c to be preventing such things all by itself.  Per
experimentation with a case suggested by Cody Cutrer.

12 years agoImprove connectMaintenanceDatabase() error reporting.
Robert Haas [Wed, 21 Mar 2012 14:56:26 +0000 (10:56 -0400)]
Improve connectMaintenanceDatabase() error reporting.

The prior coding instructs the user to pick an alternative maintenance
database, but this is overly clever, since it obscures whatever the real
cause of the failure is.

Josh Kupershmidt

12 years agoAdd some CHECK_FOR_INTERRUPTS() calls to the heap-sort call path.
Robert Haas [Wed, 21 Mar 2012 01:00:11 +0000 (21:00 -0400)]
Add some CHECK_FOR_INTERRUPTS() calls to the heap-sort call path.

I broke this in commit 337b6f5ecf05b21b5e997986884d097d60e4e3d0, which
among other things arranged for quicksorts to CHECK_FOR_INTERRUPTS()
slightly less frequently.  Sadly, it also arranged for heapsorts to
CHECK_FOR_INTERRUPTS() much less frequently.  Repair.

12 years agoImprove the -l (limit) option recently added to contrib/vacuumlo.
Tom Lane [Tue, 20 Mar 2012 23:05:08 +0000 (19:05 -0400)]
Improve the -l (limit) option recently added to contrib/vacuumlo.

Instead of just stopping after removing an arbitrary subset of orphaned
large objects, commit and start a new transaction after each -l objects.
This is just as effective as the original patch at limiting the number of
locks used, and it doesn't require doing the OID collection process
repeatedly to get everything.  Since the option no longer changes the
fundamental behavior of vacuumlo, and it avoids a known server-side
limitation, enable it by default (with a default limit of 1000 LOs per
transaction).

In passing, be more careful about properly quoting the names of tables
and fields, and do some other cosmetic cleanup.

12 years agopg_dump: get rid of die_horribly
Alvaro Herrera [Tue, 20 Mar 2012 21:38:11 +0000 (18:38 -0300)]
pg_dump: get rid of die_horribly

The old code was using exit_horribly or die_horribly other depending on
whether it had an ArchiveHandle on which to close the connection or not;
but there were places that were passing a NULL ArchiveHandle to
die_horribly, and other places that used exit_horribly while having an
AH available.  So there wasn't all that much consistency.

Improve the situation by keeping only one of the routines, and instead
of having to pass the AH down from the caller, arrange for it to be
present for an on_exit_nicely callback to operate on.

Author: Joachim Wieland
Some tweaks by me

Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump"
saga.

12 years agoFix trigger example code to match header changes
Alvaro Herrera [Tue, 20 Mar 2012 19:50:18 +0000 (16:50 -0300)]
Fix trigger example code to match header changes

I should have done this in b93f5a5673b4bb09e14eb80fe28aa21fc20a6271 but
didn't notice the problem at the time.

Per report from Marco Nenciarini

12 years agoUpdate struct Trigger in docs
Alvaro Herrera [Tue, 20 Mar 2012 16:14:16 +0000 (13:14 -0300)]
Update struct Trigger in docs

12 years agoRemove stray word from sepgsql documentation.
Robert Haas [Tue, 20 Mar 2012 19:10:33 +0000 (15:10 -0400)]
Remove stray word from sepgsql documentation.

12 years agopg_upgrade: Add new generated file to .gitignore
Peter Eisentraut [Tue, 20 Mar 2012 18:40:31 +0000 (20:40 +0200)]
pg_upgrade: Add new generated file to .gitignore

12 years agopg_dump: Remove undocumented "files" output format
Peter Eisentraut [Tue, 20 Mar 2012 18:38:20 +0000 (20:38 +0200)]
pg_dump: Remove undocumented "files" output format

This was for demonstration only, and now it was creating compiler
warnings from zlib without an obvious fix (see also
d923125b77c5d698bb8107a533a21627582baa43), let's just remove it.  The
"directory" format is presumably similar enough anyway.

12 years agoRestructure SELECT INTO's parsetree representation into CreateTableAsStmt.
Tom Lane [Tue, 20 Mar 2012 01:37:19 +0000 (21:37 -0400)]
Restructure SELECT INTO's parsetree representation into CreateTableAsStmt.

Making this operation look like a utility statement seems generally a good
idea, and particularly so in light of the desire to provide command
triggers for utility statements.  The original choice of representing it as
SELECT with an IntoClause appendage had metastasized into rather a lot of
places, unfortunately, so that this patch is a great deal more complicated
than one might at first expect.

In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
subcommands required restructuring some EXPLAIN-related APIs.  Add-on code
that calls ExplainOnePlan or ExplainOneUtility, or uses
ExplainOneQuery_hook, will need adjustment.

Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
which formerly were accepted though undocumented, are no longer accepted.
The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
The CREATE RULE case doesn't seem to have much real-world use (since the
rule would work only once before failing with "table already exists"),
so we'll not bother with that one.

Both SELECT INTO and CREATE TABLE AS still return a command tag of
"SELECT nnnn".  There was some discussion of returning "CREATE TABLE nnnn",
but for the moment backwards compatibility wins the day.

Andres Freund and Tom Lane

12 years agopg_dump: fix double free of query results
Alvaro Herrera [Mon, 19 Mar 2012 20:52:20 +0000 (17:52 -0300)]
pg_dump: fix double free of query results

This bug was introduced while refactoring in commit 1631598e --- no need
to back-patch.

Bug report and fix from Joachim Wieland.

12 years agoplperl: Package-qualify _TD
Alvaro Herrera [Mon, 19 Mar 2012 20:29:05 +0000 (17:29 -0300)]
plperl: Package-qualify _TD

Failing to do so causes trigger invocation to fail when they are nested
within a function invocation that changes the current package.

Backpatch to 9.1; previous releases used a different method to obtain
_TD.  Per bug report from Mark Murawski (bug #6511)

Author: Alex Hunsaker

12 years agoIn pg_upgrade, remove dependency on pg_config, as that might not be in
Bruce Momjian [Mon, 19 Mar 2012 13:31:50 +0000 (09:31 -0400)]
In pg_upgrade, remove dependency on pg_config, as that might not be in
the non-development install.  Instead, use the LOAD mechanism to check
for the pg_upgrade_support shared object, like we do for other shared
object checks.

Backpatch to 9.1.

Report from Àlvaro

12 years agoHonor inputdir and outputdir when converting regression files.
Andrew Dunstan [Sat, 17 Mar 2012 21:24:15 +0000 (17:24 -0400)]
Honor inputdir and outputdir when converting regression files.

When converting source files, pg_regress' inputdir and outputdir options were
ignored when computing the locations of the destination files. In consequence,
these options were effectively unusable when the regression inputs need to
be adjusted by pg_regress. This patch makes pg_regress put the converted files
in the same place that these options specify non-converted input or results
files are to be found. Backpatched to all live branches.

12 years agoIn pg_upgrade, move new echo quote define into include file.
Bruce Momjian [Sat, 17 Mar 2012 13:56:47 +0000 (09:56 -0400)]
In pg_upgrade, move new echo quote define into include file.

12 years agoAdd note about column privilege behavior to REVOKE reference page
Peter Eisentraut [Sat, 17 Mar 2012 08:34:00 +0000 (10:34 +0200)]
Add note about column privilege behavior to REVOKE reference page

suggested by Josh Berkus

12 years agoIn pg_upgrade, create a script to incrementally generate more accurate
Bruce Momjian [Fri, 16 Mar 2012 22:54:11 +0000 (18:54 -0400)]
In pg_upgrade, create a script to incrementally generate more accurate
optimizer statistics so the cluster can be made available sooner.

12 years agolibpq: Fix minor memory leaks
Peter Eisentraut [Fri, 16 Mar 2012 18:30:19 +0000 (20:30 +0200)]
libpq: Fix minor memory leaks

When using connection info arrays with a conninfo string in the dbname
slot, some memory would be leaked if an error occurred while
processing the following array slots.

found by Coverity

12 years agopsql: Remove inappropriate const qualifiers
Peter Eisentraut [Fri, 16 Mar 2012 18:03:38 +0000 (20:03 +0200)]
psql: Remove inappropriate const qualifiers

Since mbvalidate() can alter the string it validates, having the
callers claim that the strings they accept are const is inappropriate.

12 years agopg_dump: Fix crash with invalid pg_cast row
Peter Eisentraut [Fri, 16 Mar 2012 17:55:41 +0000 (19:55 +0200)]
pg_dump: Fix crash with invalid pg_cast row

An invalid combination of pg_cast.castfunc and pg_cast.castmethod
would result in a segmentation fault.  Now it prints a warning.

found by Coverity

12 years agopg_restore: Fix memory and file descriptor leak with directory format
Peter Eisentraut [Fri, 16 Mar 2012 17:53:31 +0000 (19:53 +0200)]
pg_restore: Fix memory and file descriptor leak with directory format

found by Coverity

12 years agobackend: Fix minor memory leak in configuration file processing
Peter Eisentraut [Fri, 16 Mar 2012 17:51:43 +0000 (19:51 +0200)]
backend: Fix minor memory leak in configuration file processing

Just for consistency with the other code paths.

found by Coverity

12 years agoImprove commentary in match_pathkeys_to_index().
Tom Lane [Fri, 16 Mar 2012 18:07:21 +0000 (14:07 -0400)]
Improve commentary in match_pathkeys_to_index().

For a little while there I thought match_pathkeys_to_index() was broken
because it wasn't trying to match index columns to pathkeys in order.
Actually that's correct, because GiST can support ordering operators
on any random collection of index columns, but it sure needs a comment.

12 years agoRevisit handling of UNION ALL subqueries with non-Var output columns.
Tom Lane [Fri, 16 Mar 2012 17:11:12 +0000 (13:11 -0400)]
Revisit handling of UNION ALL subqueries with non-Var output columns.

In commit 57664ed25e5dea117158a2e663c29e60b3546e1c I tried to fix a bug
reported by Teodor Sigaev by making non-simple-Var output columns distinct
(by wrapping their expressions with dummy PlaceHolderVar nodes).  This did
not work too well.  Commit b28ffd0fcc583c1811e5295279e7d4366c3cae6c fixed
some ensuing problems with matching to child indexes, but per a recent
report from Claus Stadler, constraint exclusion of UNION ALL subqueries was
still broken, because constant-simplification didn't handle the injected
PlaceHolderVars well either.  On reflection, the original patch was quite
misguided: there is no reason to expect that EquivalenceClass child members
will be distinct.  So instead of trying to make them so, we should ensure
that we can cope with the situation when they're not.

Accordingly, this patch reverts the code changes in the above-mentioned
commits (though the regression test cases they added stay).  Instead, I've
added assorted defenses to make sure that duplicate EC child members don't
cause any problems.  Teodor's original problem ("MergeAppend child's
targetlist doesn't match MergeAppend") is addressed more directly by
revising prepare_sort_from_pathkeys to let the parent MergeAppend's sort
list guide creation of each child's sort list.

In passing, get rid of add_sort_column; as far as I can tell, testing for
duplicate sort keys at this stage is dead code.  Certainly it doesn't
trigger often enough to be worth expending cycles on in ordinary queries.
And keeping the test would've greatly complicated the new logic in
prepare_sort_from_pathkeys, because comparing pathkey list entries against
a previous output array requires that we not skip any entries in the list.

Back-patch to 9.1, like the previous patches.  The only known issue in
this area that wasn't caused by the ill-advised previous patches was the
MergeAppend planning failure, which of course is not relevant before 9.1.
It's possible that we need some of the new defenses against duplicate child
EC entries in older branches, but until there's some clear evidence of that
I'm going to refrain from back-patching further.

12 years agoAdd comments explaining why our Itanium spinlock implementation is safe.
Heikki Linnakangas [Fri, 16 Mar 2012 08:14:45 +0000 (10:14 +0200)]
Add comments explaining why our Itanium spinlock implementation is safe.

12 years agoA couple more fixes for the sepgsql documentation.
Robert Haas [Thu, 15 Mar 2012 20:49:44 +0000 (16:49 -0400)]
A couple more fixes for the sepgsql documentation.

12 years agoCopy editing of sepgsql documentation.
Robert Haas [Thu, 15 Mar 2012 20:37:40 +0000 (16:37 -0400)]
Copy editing of sepgsql documentation.

12 years agosepgsql_setcon().
Robert Haas [Thu, 15 Mar 2012 20:08:40 +0000 (16:08 -0400)]
sepgsql_setcon().

This is intended as infrastructure to allow sepgsql to cooperate with
connection pooling software, by allowing the effective security label
to be set for each new connection.

KaiGai Kohei, reviewed by Yeb Havinga.

12 years agoAdd const qualifier to tzn returned by timestamp2tm()
Peter Eisentraut [Thu, 15 Mar 2012 19:17:19 +0000 (21:17 +0200)]
Add const qualifier to tzn returned by timestamp2tm()

The tzn value might come from tm->tm_zone, which libc declares as
const, so it's prudent that the upper layers know about this as well.

12 years agoRemove unused tzn arguments for timestamp2tm()
Peter Eisentraut [Thu, 15 Mar 2012 19:13:35 +0000 (21:13 +0200)]
Remove unused tzn arguments for timestamp2tm()

12 years agoUppercase pg_upgrade status output title.
Bruce Momjian [Wed, 14 Mar 2012 23:22:01 +0000 (19:22 -0400)]
Uppercase pg_upgrade status output title.

12 years agoImprove EncodeDateTime and EncodeTimeOnly APIs
Peter Eisentraut [Wed, 14 Mar 2012 21:03:34 +0000 (23:03 +0200)]
Improve EncodeDateTime and EncodeTimeOnly APIs

Use an explicit argument to tell whether to include the time zone in
the output, rather than using some undocumented pointer magic.

12 years agoAdd missing va_end() calls
Peter Eisentraut [Wed, 14 Mar 2012 20:47:21 +0000 (22:47 +0200)]
Add missing va_end() calls

found by Coverity

12 years agoCOPY: Add an assertion
Peter Eisentraut [Wed, 14 Mar 2012 20:44:40 +0000 (22:44 +0200)]
COPY: Add an assertion

This is for tools such as Coverity that don't know that the grammar
enforces that the case of not having a relation (but instead a query)
cannot happen in the FROM case.

12 years agoAdd additional safety check against invalid backup label file
Peter Eisentraut [Wed, 14 Mar 2012 20:41:50 +0000 (22:41 +0200)]
Add additional safety check against invalid backup label file

It was already checking for invalid data after "BACKUP FROM", but
would possibly crash if "BACKUP FROM" was missing altogether.

found by Coverity

12 years agopg_dump: Fix some minor memory leaks
Peter Eisentraut [Tue, 13 Mar 2012 19:34:54 +0000 (21:34 +0200)]
pg_dump: Fix some minor memory leaks

Although we often don't care about freeing all memory in pg_dump,
these functions already freed the same memory in other code paths, so
we might as well do it consistently.

found by Coverity

12 years agoPatch some corner-case bugs in pl/python.
Tom Lane [Tue, 13 Mar 2012 19:26:32 +0000 (15:26 -0400)]
Patch some corner-case bugs in pl/python.

Dave Malcolm of Red Hat is working on a static code analysis tool for
Python-related C code.  It reported a number of problems in plpython,
most of which were failures to check for NULL results from object-creation
functions, so would only be an issue in very-low-memory situations.

Patch in HEAD and 9.1.  We could go further back but it's not clear that
these issues are important enough to justify the work.

Jan Urbański

12 years agoFix minor memory leak in PLy_typeinfo_dealloc().
Tom Lane [Tue, 13 Mar 2012 17:28:11 +0000 (13:28 -0400)]
Fix minor memory leak in PLy_typeinfo_dealloc().

We forgot to free the per-attribute array element descriptors.

Jan Urbański

12 years agoCreate a stack of pl/python "execution contexts".
Tom Lane [Tue, 13 Mar 2012 17:19:06 +0000 (13:19 -0400)]
Create a stack of pl/python "execution contexts".

This replaces the former global variable PLy_curr_procedure, and provides
a place to stash per-call-level information.  In particular we create a
per-call-level scratch memory context.

For the moment, the scratch context is just used to avoid leaking memory
from datatype output function calls in PLyDict_FromTuple.  There probably
will be more use-cases in future.

Although this is a fix for a pre-existing memory leakage bug, it seems
sufficiently invasive to not want to back-patch; it feels better as part
of the major rearrangement of plpython code that we've already done as
part of 9.2.

Jan Urbański

12 years agopgstattuple: Use a BufferAccessStrategy object to avoid cache-trashing.
Robert Haas [Tue, 13 Mar 2012 13:51:03 +0000 (09:51 -0400)]
pgstattuple: Use a BufferAccessStrategy object to avoid cache-trashing.

Jaime Casanova, reviewed by Noah Misch, slightly modified by me.

12 years agopgstattuple: Add new error case for spgist indexes.
Robert Haas [Tue, 13 Mar 2012 13:35:55 +0000 (09:35 -0400)]
pgstattuple: Add new error case for spgist indexes.

Extracted from a larger patch by Jaime Casanova, reviewed by Noah Misch.
I think this error message could use some more extensive revision, but
this at least makes the handling of spgist consistent with what we do for
other types of indexes that this code doesn't know how to handle.

12 years agoIn pg_upgrade, add various logging improvements:
Bruce Momjian [Mon, 12 Mar 2012 23:47:54 +0000 (19:47 -0400)]
In pg_upgrade, add various logging improvements:

add ability to control permissions of created files
have psql echo its queries for easier debugging
output four separate log files, and delete them on success
add -r/--retain option to keep log files after success
make logs file append-only
remove -g/-G/-l logging options
sugggest tailing appropriate log file on failure
enhance -v/--verbose behavior

12 years agoFix SPGiST vacuum algorithm to handle concurrent tuple motion properly.
Tom Lane [Mon, 12 Mar 2012 20:10:05 +0000 (16:10 -0400)]
Fix SPGiST vacuum algorithm to handle concurrent tuple motion properly.

A leaf tuple that we need to delete could get moved as a consequence of an
insertion happening concurrently with the VACUUM scan.  If it moves from a
page past the current scan point to a page before, we'll miss it, which is
not acceptable.  Hence, when we see a leaf-page REDIRECT that could have
been made since our scan started, chase down the redirection pointer much
as if we were doing a normal index search, and be sure to vacuum every page
it leads to.  This fixes the issue because, if the tuple was on page N at
the instant we start our scan, we will surely find it as a consequence of
chasing the redirect from page N, no matter how much it moves around in
between.  Problem noted by Takashi Yamamoto.

12 years agoUse correct sizeof operand in qsort call
Peter Eisentraut [Mon, 12 Mar 2012 18:56:13 +0000 (20:56 +0200)]
Use correct sizeof operand in qsort call

Probably no practical impact, since all pointers ought to have the
same size, but it was wrong nonetheless.  Found by Coverity.

12 years agoAdd comment for missing break in switch
Peter Eisentraut [Mon, 12 Mar 2012 18:55:09 +0000 (20:55 +0200)]
Add comment for missing break in switch

For clarity, following other sites, and to silence Coverity.

12 years agoRemove tabs in SGML files
Bruce Momjian [Mon, 12 Mar 2012 14:13:42 +0000 (10:13 -0400)]
Remove tabs in SGML files

12 years agoMake INSERT/UPDATE queries depend on their specific target columns.
Tom Lane [Sun, 11 Mar 2012 22:14:23 +0000 (18:14 -0400)]
Make INSERT/UPDATE queries depend on their specific target columns.

We have always created a whole-table dependency for the target relation,
but that's not really good enough, as it doesn't prevent scenarios such
as dropping an individual target column or altering its type.  So we
have to create an individual dependency for each target column, as well.

Per report from Bill MacArthur of a rule containing UPDATE breaking
after such an alteration.  Note that this patch doesn't try to make
such cases work, only to ensure that the attempted ALTER TABLE throws
an error telling you it can't cope with adjusting the rule.

This is a long-standing bug, but given the lack of prior reports
I'm not going to risk back-patching it.  A back-patch wouldn't do
anything to fix existing rules' dependency lists, anyway.

12 years agoMake parameter name consistent with syntax summary.
Tom Lane [Sun, 11 Mar 2012 20:56:26 +0000 (16:56 -0400)]
Make parameter name consistent with syntax summary.

Thomas Hunger

12 years agoFix documented type of t_infomask2.
Tom Lane [Sun, 11 Mar 2012 20:53:04 +0000 (16:53 -0400)]
Fix documented type of t_infomask2.

Per Koizumi Satoru

12 years agoTeach SPGiST to store nulls and do whole-index scans.
Tom Lane [Sun, 11 Mar 2012 20:29:04 +0000 (16:29 -0400)]
Teach SPGiST to store nulls and do whole-index scans.

This patch fixes the other major compatibility-breaking limitation of
SPGiST, that it didn't store anything for null values of the indexed
column, and so could not support whole-index scans or "x IS NULL"
tests.  The approach is to create a wholly separate search tree for
the null entries, and use fixed "allTheSame" insertion and search
rules when processing this tree, instead of calling the index opclass
methods.  This way the opclass methods do not need to worry about
dealing with nulls.

Catversion bump is for pg_am updates as well as the change in on-disk
format of SPGiST indexes; there are some tweaks in SPGiST WAL records
as well.

Heavily rewritten version of a patch by Oleg Bartunov and Teodor Sigaev.
(The original also stored nulls separately, but it reused GIN code to do
so; which required undesirable compromises in the on-disk format, and
would likely lead to bugs due to the GIN code being required to work in
two very different contexts.)

12 years agoRemoved redundant "the" from ecpg's docs.
Michael Meskes [Sun, 11 Mar 2012 11:25:52 +0000 (12:25 +0100)]
Removed redundant "the" from ecpg's docs.

Typo spotted by Erik Rijkers.

12 years agoAdd description for --no-locale and --text-search-config.
Tatsuo Ishii [Sat, 10 Mar 2012 23:23:20 +0000 (08:23 +0900)]
Add description for --no-locale and --text-search-config.

12 years agoAdd more detail to error message for invalid arguments for server process
Peter Eisentraut [Sat, 10 Mar 2012 23:52:05 +0000 (01:52 +0200)]
Add more detail to error message for invalid arguments for server process

It now prints the argument that was at fault.

Also fix a small misbehavior where the error message issued by
getopt() would complain about a program named "--single", because
that's what argv[0] is in the server process.

12 years agoRestructure SPGiST opclass interface API to support whole-index scans.
Tom Lane [Sat, 10 Mar 2012 23:36:49 +0000 (18:36 -0500)]
Restructure SPGiST opclass interface API to support whole-index scans.

The original API definition was incapable of supporting whole-index scans
because there was no way to invoke leaf-value reconstruction without
checking any qual conditions.  Also, it was inefficient for
multiple-qual-condition scans because value reconstruction got done over
again for each qual condition, and because other internal work in the
consistent functions likewise had to be done for each qual.  To fix these
issues, pass the whole scankey array to the opclass consistent functions,
instead of only letting them see one item at a time.  (Essentially, the
loop over scankey entries is now inside the consistent functions not
outside them.  This makes the consistent functions a bit more complicated,
but not unreasonably so.)

In itself this commit does nothing except save a few cycles in
multiple-qual-condition index scans, since we can't support whole-index
scans on SPGiST indexes until nulls are included in the index.  However,
I consider this a must-fix for 9.2 because once we release it will get
very much harder to change the opclass API definition.

12 years agoAdd support for renaming constraints
Peter Eisentraut [Sat, 10 Mar 2012 18:19:13 +0000 (20:19 +0200)]
Add support for renaming constraints

reviewed by Josh Berkus and Dimitri Fontaine

12 years agosepgsql DROP support.
Robert Haas [Fri, 9 Mar 2012 20:18:45 +0000 (15:18 -0500)]
sepgsql DROP support.

KaiGai Kohei

12 years agoExtend object access hook framework to support arguments, and DROP.
Robert Haas [Fri, 9 Mar 2012 19:34:56 +0000 (14:34 -0500)]
Extend object access hook framework to support arguments, and DROP.

This allows loadable modules to get control at drop time, perhaps for the
purpose of performing additional security checks or to log the event.
The initial purpose of this code is to support sepgsql, but other
applications should be possible as well.

KaiGai Kohei, reviewed by me.

12 years agoRevise FDW planning API, again.
Tom Lane [Fri, 9 Mar 2012 17:48:48 +0000 (12:48 -0500)]
Revise FDW planning API, again.

Further reflection shows that a single callback isn't very workable if we
desire to let FDWs generate multiple Paths, because that forces the FDW to
do all work necessary to generate a valid Plan node for each Path.  Instead
split the former PlanForeignScan API into three steps: GetForeignRelSize,
GetForeignPaths, GetForeignPlan.  We had already bit the bullet of breaking
the 9.1 FDW API for 9.2, so this shouldn't cause very much additional pain,
and it's substantially more flexible for complex FDWs.

Add an fdw_private field to RelOptInfo so that the new functions can save
state there rather than possibly having to recalculate information two or
three times.

In addition, we'd not thought through what would be needed to allow an FDW
to set up subexpressions of its choice for runtime execution.  We could
treat ForeignScan.fdw_private as an executable expression but that seems
likely to break existing FDWs unnecessarily (in particular, it would
restrict the set of node types allowable in fdw_private to those supported
by expression_tree_walker).  Instead, invent a separate field fdw_exprs
which will receive the postprocessing appropriate for expression trees.
(One field is enough since it can be a list of expressions; also, we assume
the corresponding expression state tree(s) will be held within fdw_state,
so we don't need to add anything to ForeignScanState.)

Per review of Hanada Shigeru's pgsql_fdw patch.  We may need to tweak this
further as we continue to work on that patch, but to me it feels a lot
closer to being right now.

12 years agoUpdate outdated comment. HeapTupleHeader.t_natts field doesn't exist anymore.
Heikki Linnakangas [Fri, 9 Mar 2012 06:07:56 +0000 (08:07 +0200)]
Update outdated comment. HeapTupleHeader.t_natts field doesn't exist anymore.

Kevin Grittner

12 years agopsql: Remove useless code
Peter Eisentraut [Thu, 8 Mar 2012 21:13:51 +0000 (23:13 +0200)]
psql: Remove useless code

Apparently a copy-and-paste mistake introduced in
8ddd22f2456af0155f9c183894f481203e86b76e.

found by Coverity

12 years agoFix some issues with temp/transient tables in extension scripts.
Tom Lane [Thu, 8 Mar 2012 20:52:26 +0000 (15:52 -0500)]
Fix some issues with temp/transient tables in extension scripts.

Phil Sorber reported that a rewriting ALTER TABLE within an extension
update script failed, because it creates and then drops a placeholder
table; the drop was being disallowed because the table was marked as an
extension member.  We could hack that specific case but it seems likely
that there might be related cases now or in the future, so the most
practical solution seems to be to create an exception to the general rule
that extension member objects can only be dropped by dropping the owning
extension.  To wit: if the DROP is issued within the extension's own
creation or update scripts, we'll allow it, implicitly performing an
"ALTER EXTENSION DROP object" first.  This will simplify cases such as
extension downgrade scripts anyway.

No docs change since we don't seem to have documented the idea that you
would need ALTER EXTENSION DROP for such an action to begin with.

Also, arrange for explicitly temporary tables to not get linked as
extension members in the first place, and the same for the magic
pg_temp_nnn schemas that are created to hold them.  This prevents assorted
unpleasant results if an extension script creates a temp table: the forced
drop at session end would either fail or remove the entire extension, and
neither of those outcomes is desirable.  Note that this doesn't fix the
ALTER TABLE scenario, since the placeholder table is not temp (unless the
table being rewritten is).

Back-patch to 9.1.

12 years agoecpg: Fix off-by-one error in memory copying
Peter Eisentraut [Thu, 8 Mar 2012 20:29:01 +0000 (22:29 +0200)]
ecpg: Fix off-by-one error in memory copying

In a rare case, one byte past the end of memory belonging to the
sqlca_t structure would be written to.

found by Coverity

12 years agoecpg: Fix rare memory leaks
Peter Eisentraut [Thu, 8 Mar 2012 20:21:12 +0000 (22:21 +0200)]
ecpg: Fix rare memory leaks

found by Coverity

12 years agoSilence warning about unused variable, when building without assertions.
Heikki Linnakangas [Thu, 8 Mar 2012 09:10:02 +0000 (11:10 +0200)]
Silence warning about unused variable, when building without assertions.