Commit Graph

33346 Commits

Author SHA1 Message Date
Tom Lane f2386d7136 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.
2012-03-22 00:46:03 -04:00
Peter Eisentraut 0e85abd658 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.
2012-03-21 23:33:10 +02:00
Peter Eisentraut 621eb156f1 Add installing entab to pgindent instructions
And minor other pgindent documentation tweaks.
2012-03-21 23:33:10 +02:00
Robert Haas 5b9c1e6d52 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.
2012-03-21 14:52:44 -04:00
Tom Lane f70f095c90 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.
2012-03-21 14:09:39 -04:00
Robert Haas 99081c63e4 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
2012-03-21 10:56:26 -04:00
Robert Haas aefa6d163e Add some CHECK_FOR_INTERRUPTS() calls to the heap-sort call path.
I broke this in commit 337b6f5ecf, 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.
2012-03-20 21:26:39 -04:00
Tom Lane 64c604898e 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.
2012-03-20 19:05:44 -04:00
Alvaro Herrera 9d23a70d51 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.
2012-03-20 18:58:00 -03:00
Alvaro Herrera b251cf3193 Fix trigger example code to match header changes
I should have done this in b93f5a5673 but
didn't notice the problem at the time.

Per report from Marco Nenciarini
2012-03-20 16:50:18 -03:00
Alvaro Herrera 438269eb10 Update struct Trigger in docs 2012-03-20 16:18:59 -03:00
Robert Haas 0b43edbca7 Remove stray word from sepgsql documentation. 2012-03-20 15:10:33 -04:00
Peter Eisentraut 1b12c3e836 pg_upgrade: Add new generated file to .gitignore 2012-03-20 20:40:31 +02:00
Peter Eisentraut 19f45565f5 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
d923125b77), let's just remove it.  The
"directory" format is presumably similar enough anyway.
2012-03-20 20:39:59 +02:00
Tom Lane 9dbf2b7d75 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
2012-03-19 21:38:12 -04:00
Alvaro Herrera 77503a7638 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.
2012-03-19 17:55:51 -03:00
Alvaro Herrera 814e08e895 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
2012-03-19 17:29:05 -03:00
Bruce Momjian 02b183acb4 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
2012-03-19 09:31:50 -04:00
Andrew Dunstan e3fc4a97bc 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.
2012-03-17 17:24:15 -04:00
Bruce Momjian ced53c38d7 In pg_upgrade, move new echo quote define into include file. 2012-03-17 09:56:56 -04:00
Peter Eisentraut 313d29f740 Add note about column privilege behavior to REVOKE reference page
suggested by Josh Berkus
2012-03-17 10:34:00 +02:00
Bruce Momjian faec2815c8 In pg_upgrade, create a script to incrementally generate more accurate
optimizer statistics so the cluster can be made available sooner.
2012-03-16 18:54:23 -04:00
Peter Eisentraut d4318483e1 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
2012-03-16 20:35:00 +02:00
Peter Eisentraut 598bb8cdbd 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.
2012-03-16 20:35:00 +02:00
Peter Eisentraut 359dea2859 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
2012-03-16 20:34:59 +02:00
Peter Eisentraut d8e5b3427a pg_restore: Fix memory and file descriptor leak with directory format
found by Coverity
2012-03-16 20:34:59 +02:00
Peter Eisentraut 693ff85d47 backend: Fix minor memory leak in configuration file processing
Just for consistency with the other code paths.

found by Coverity
2012-03-16 20:34:59 +02:00
Tom Lane b67ad046e6 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.
2012-03-16 14:07:21 -04:00
Tom Lane dd4134ea56 Revisit handling of UNION ALL subqueries with non-Var output columns.
In commit 57664ed25e 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 b28ffd0fcc 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.
2012-03-16 13:11:55 -04:00
Heikki Linnakangas aef5fe7efe Add comments explaining why our Itanium spinlock implementation is safe. 2012-03-16 10:14:45 +02:00
Robert Haas 4012810a68 A couple more fixes for the sepgsql documentation. 2012-03-15 16:49:44 -04:00
Robert Haas d0ed9efdf7 Copy editing of sepgsql documentation. 2012-03-15 16:37:40 -04:00
Robert Haas 523176cbf1 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.
2012-03-15 16:08:40 -04:00
Peter Eisentraut eb990a2b9e 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.
2012-03-15 21:17:19 +02:00
Peter Eisentraut 531e60aec0 Remove unused tzn arguments for timestamp2tm() 2012-03-15 21:13:35 +02:00
Bruce Momjian 7c8cfed78a Uppercase pg_upgrade status output title. 2012-03-14 19:22:11 -04:00
Peter Eisentraut ad4fb0d0d2 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.
2012-03-14 23:03:34 +02:00
Peter Eisentraut 942b63193c Add missing va_end() calls
found by Coverity
2012-03-14 22:47:21 +02:00
Peter Eisentraut 6f018c6dda 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.
2012-03-14 22:44:40 +02:00
Peter Eisentraut e684ab5e1e 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
2012-03-14 22:41:50 +02:00
Peter Eisentraut acfaa596cc 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
2012-03-13 21:36:43 +02:00
Tom Lane 5cd72c7a7c 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
2012-03-13 15:26:32 -04:00
Tom Lane a14fa84693 Fix minor memory leak in PLy_typeinfo_dealloc().
We forgot to free the per-attribute array element descriptors.

Jan Urbański
2012-03-13 13:28:11 -04:00
Tom Lane ed75380bda 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
2012-03-13 13:19:06 -04:00
Robert Haas 2e46bf6711 pgstattuple: Use a BufferAccessStrategy object to avoid cache-trashing.
Jaime Casanova, reviewed by Noah Misch, slightly modified by me.
2012-03-13 09:51:45 -04:00
Robert Haas 97c85098de 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.
2012-03-13 09:38:57 -04:00
Bruce Momjian 717f6d6085 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
2012-03-12 19:48:03 -04:00
Tom Lane b4af1c25bb 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.
2012-03-12 16:10:28 -04:00
Peter Eisentraut bad250f4f3 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.
2012-03-12 20:56:13 +02:00
Peter Eisentraut c9f310d377 Add comment for missing break in switch
For clarity, following other sites, and to silence Coverity.
2012-03-12 20:55:09 +02:00