Commit Graph

24082 Commits

Author SHA1 Message Date
Tom Lane
bcc66d009b Fix a couple of issues with pg_dump's handling of inheritance child tables
that have default expressions different from their parent.  First, if the
parent table's default expression has to be split out as a separate
ALTER TABLE command, we need a dependency constraint to ensure that the
child's command is given second.  This is because the ALTER TABLE on the
parent will propagate to the child.  (We can't prevent that by using ONLY on
the parent's command, since it's possible that other children exist that
should receive the inherited default.)  Second, if the child has a NULL
default where the parent does not, we have to explicitly say DEFAULT NULL on
the child in order for this state to be preserved after reload.  (The latter
actually doesn't work right because of a backend bug, but that is a separate
issue.)

Backpatch as far as 8.0.  7.x pg_dump has enough issues with altered tables
(due to lack of dependency analysis) that trying to fix this one doesn't seem
very productive.
2007-10-28 19:08:08 +00:00
Tom Lane
e40ca77fad Change have_join_order_restriction() so that we do not force a clauseless join
if either of the input relations can legally be joined to any other rels using
join clauses.  This avoids uselessly (and expensively) considering a lot of
really stupid join paths when there is a join restriction with a large
footprint, that is, lots of relations inside its LHS or RHS.  My patch of
15-Feb-2007 had been causing the code to consider joining *every* combination
of rels inside such a group, which is exponentially bad :-(.  With this
behavior, clauseless bushy joins will be done if necessary, but they'll be
put off as long as possible.  Per report from Jakub Ouhrabka.

Backpatch to 8.2.  We might someday want to backpatch to 8.1 as well, but 8.1
does not have the problem for OUTER JOIN nests, only for IN-clauses, so it's
not clear anyone's very likely to hit it in practice; and the current patch
doesn't apply cleanly to 8.1.
2007-10-26 18:10:58 +00:00
Tom Lane
9f3309858f Ugly patch to make ALTER SEQUENCE OWNED BY not affect the currval() state
of the sequence.  Since OWNED BY never existed before 8.2, this seems
unlikely to create any compatibility issues.  Other forms of ALTER SEQUENCE
continue to do what they did before, namely update currval to match the
sequence's actual last_val.  That seems wrong on consideration, but we'll
not change it in a minor release --- 8.3 will make that fix.
2007-10-25 19:15:01 +00:00
Tom Lane
72fb03b8c8 Fix an error in make_outerjoininfo introduced by my patch of 30-Aug: the code
neglected to test whether an outer join's join-condition actually refers to
the lower outer join it is looking at.  (The comment correctly described what
was supposed to happen, but the code didn't do it...)  This often resulted in
adding an unnecessary constraint on the join order of the two outer joins,
which was bad enough.  However, it also seems to expose a performance
problem in an older patch (from 15-Feb): once we've decided that there is a
join ordering constraint, we will start trying clauseless joins between every
combination of rels within the constraint, which pointlessly eats up lots of
time and space if there are numerous rels below the outer join.  That probably
needs to be revisited :-(.  Per gripe from Jakub Ouhrabka.
2007-10-24 20:54:33 +00:00
Tom Lane
9632b06ec7 Back-patch some plpython patches previously made only in HEAD: changes of
3-Apr and 4-Apr to declare interface functions properly and eliminate casts,
thereby fixing potential problems on 64-bit machines; and changes of 13-Jul
to volatile-qualify some variables to suppress compiler warnings.
Per discussion, we're only worrying about Python 2.5 in PG 8.2 and up,
so no need to patch further back.
2007-10-15 15:53:12 +00:00
Tom Lane
5b8328b936 Fix ALTER COLUMN TYPE to preserve the tablespace and reloptions of indexes
it affects.  The original coding neglected tablespace entirely (causing
the indexes to move to the database's default tablespace) and for an index
belonging to a UNIQUE or PRIMARY KEY constraint, it would actually try to
assign the parent table's reloptions to the index :-(.  Per bug #3672 and
subsequent investigation.

8.0 and 8.1 did not have reloptions, but the tablespace bug is present.
2007-10-13 15:55:49 +00:00
Tom Lane
ef3ff3eee4 Ensure that the result of evaluating a function during constant-expression
simplification gets detoasted before it is incorporated into a Const node.
Otherwise, if an immutable function were to return a TOAST pointer (an
unlikely case, but it can be made to happen), we would end up with a plan
that depends on the continued existence of the out-of-line toast datum.
2007-10-11 21:28:05 +00:00
Magnus Hagander
a948f7c62c Don't try to free pgpassfile since it's a stack variable.
Martin Pitt
2007-10-09 15:03:31 +00:00
Tom Lane
0969e9cc0e Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
eval_const_expressions simplifies this to just "WHERE false", but we have
already done pull_up_IN_clauses so the IN join will be done, or at least
planned, anyway.  The trouble case comes when the sub-SELECT is itself a join
and we decide to implement the IN by unique-ifying the sub-SELECT outputs:
with no remaining reference to the output Vars in WHERE, we won't have
propagated the Vars up to the upper join point, leading to "variable not found
in subplan target lists" error.  Fix by adding an extra scan of in_info_list
and forcing all Vars mentioned therein to be propagated up to the IN join
point.  Per bug report from Miroslav Sulc.
2007-10-04 20:44:55 +00:00
Tom Lane
f3c6d3daf9 Update timezone data files to release 2007h of the zic database.
Might as well have the latest when we wrap 8.3beta1.
2007-10-04 19:07:06 +00:00
Tom Lane
c008a275c2 Disallow CLUSTER using an invalid index (that is, one left over from a failed
CREATE INDEX CONCURRENTLY).  Such an index might not have entries for every
heap row and thus clustering with it would result in silent data loss.
The scenario requires a pretty foolish DBA, but still ...
2007-09-29 18:05:28 +00:00
Tom Lane
edc4d5edbe Defend against openssl libraries that fail on keys longer than 128 bits;
which is the case at least on some Solaris versions.  Marko Kreen
2007-09-29 02:18:21 +00:00
Tom Lane
4ef631fe2c Make archive recovery always start a new timeline, rather than only when a
recovery stop time was used.  This avoids a corner-case risk of trying to
overwrite an existing archived copy of the last WAL segment, and seems
simpler and cleaner all around than the original definition.  Per example
from Jon Colverson and subsequent analysis by Simon.
2007-09-29 01:36:19 +00:00
Tom Lane
3f850ee9aa Fix Assert failure in ExpandColumnRefStar --- what I thought was a can't
happen condition can happen given incorrect input.  The real problem is that
gram.y should try harder to distinguish * from "*" --- the latter is a legal
column name per spec, and someday we ought to treat it that way.  However
fixing that is too invasive for a back-patch, and it's too late for the 8.3
cycle too.  So just reduce the Assert to a plain elog for now.  Per report
from NikhilS.
2007-09-27 17:42:09 +00:00
Teodor Sigaev
d77a9018fa Fix crash of to_tsvector() function on huge input: compareWORD()
function didn't return correct result for word position greate than
limit.

Per report from Stuart Bishop <stuart@stuartbishop.net>
2007-09-26 10:17:34 +00:00
Alvaro Herrera
189f9a5bb2 Reduce the size of memory allocations by lazy vacuum when processing a small
table, by allocating just enough for a hardcoded number of dead tuples per
page.  The current estimate is 200 dead tuples per page.

Per reports from Jeff Amiel, Erik Jones and Marko Kreen, and subsequent
discussion.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: 	commands/vacuumlazy.c
CVS: ----------------------------------------------------------------------
2007-09-24 03:53:02 +00:00
Tom Lane
a4f72d5940 Fix erroneous Assert() in syslogger process start in EXEC_BACKEND case,
per ITAGAKI Takahiro.  Also, rewrite syslogger_forkexec() in hopes of
eliminating the confusion in the first place.
2007-09-22 18:19:24 +00:00
Tom Lane
a9f08b41ac Fix bogus calculation of potential output string length in translate(). 2007-09-22 05:35:52 +00:00
Neil Conway
d5e6f4f828 Prevent corr() from returning the wrong results for negative correlation
values. The previous coding essentially assumed that x = sqrt(x*x), which
does not hold for x < 0.

Thanks to Jie Zhang at Greenplum and Gavin Sherry for reporting this
issue.
2007-09-19 22:31:51 +00:00
Tom Lane
eb4f4f5b7c Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.
Seems to have been introduced in 8.1 by careless SECS_PER_DAY
search-and-replace.
2007-09-16 15:56:32 +00:00
Tom Lane
ee24168d2c Update release notes for last-minute fix. 2007-09-16 03:03:13 +00:00
Tom Lane
3d446c4767 Fix aboriginal mistake in lazy VACUUM's code for truncating away
no-longer-needed pages at the end of a table.  We thought we could throw away
pages containing HEAPTUPLE_DEAD tuples; but this is not so, because such
tuples very likely have index entries pointing at them, and we wouldn't have
removed the index entries.  The problem only emerges in a somewhat unlikely
race condition: the dead tuples have to have been inserted by a transaction
that later aborted, and this has to have happened between VACUUM's initial
scan of the page and then rechecking it for empty in count_nondeletable_pages.
But that timespan will include an index-cleaning pass, so it's not all that
hard to hit.  This seems to explain a couple of previously unsolved bug
reports.
2007-09-16 02:37:54 +00:00
Marc G. Fournier
67bc5b0ca3 update configure for 8.2.5 ... 2007-09-14 20:18:26 +00:00
Tom Lane
038be7ea31 Fix markup that doesn't work in back branches. 2007-09-14 16:13:22 +00:00
Tom Lane
b7bddb3442 Minor editorialization on release notes. 2007-09-14 15:51:04 +00:00
Tom Lane
d915af072f Fix missed version-stamping. 2007-09-14 14:05:52 +00:00
Bruce Momjian
7e82fa8b7a Clarify tar documentation about return error codes.
Backpatch to 8.2.X.
2007-09-14 13:26:36 +00:00
Bruce Momjian
6f5d343405 Update GNU tar error code documentation.
Backpatch to 8.2.X.
2007-09-14 04:16:44 +00:00
Tom Lane
62c42d82aa Remove ill-considered (not to mention undocumented) attempt to make
contrib/intarray's GIN opclass override the built-in default.  Per bug #3048
and other complaints.
2007-09-14 03:25:37 +00:00
Peter Eisentraut
cfa22b8d20 Translation updates 2007-09-13 21:15:37 +00:00
Bruce Momjian
ebeec05f8a Update Japanese FAQ, backpatch.
Jun Kuwamura
2007-09-13 03:34:23 +00:00
Bruce Momjian
7d880486d0 Update Japanese FAQ to current release number. 2007-09-12 03:11:49 +00:00
Alvaro Herrera
d41c420e3b Add a CHECK_FOR_INTERRUPTS call in the site where the vacuum delay point
was removed.
2007-09-12 02:05:36 +00:00
Tom Lane
ba438dfccd Sync timezone data with 2007g zic release. 2007-09-11 17:43:36 +00:00
Bruce Momjian
5dc3723781 Stamp releases 8.2.5, 8.1.10, 8.0.14, 7.4.18, 7.3.20.
Update FAQs for 8.2.5.
2007-09-11 17:37:30 +00:00
Bruce Momjian
6dfff52791 Stamp 2007-09-11 17:20:01 +00:00
Tom Lane
b58dba7976 Make sure that open hash table scans are cleaned up when bgwriter tries to
recover from elog(ERROR).  Problem was created by introduction of hash seq
search tracking awhile back, and affects all branches that have bgwriter;
in HEAD the disease has snuck into autovacuum and walwriter too.  (Not sure
that the latter two use hash_seq_search at the moment, but surely they might
someday.)  Per report from Sergey Koposov.
2007-09-11 17:15:40 +00:00
Teodor Sigaev
7176065273 Fix header's size of structs defines in ispell. 2007-09-11 13:04:53 +00:00
Alvaro Herrera
8f11bb1919 Make CLUSTER and REINDEX silently skip remote temp tables in their
database-wide editions.

Per report from bitsandbytes88 <at> hotmail.com and subsequent discussion.
2007-09-10 22:02:05 +00:00
Alvaro Herrera
053731ab0a Remove the vacuum_delay_point call in count_nondeletable_pages, because we hold
an exclusive lock on the table at this point, which we want to release as soon
as possible.  This is called in the phase of lazy vacuum where we truncate the
empty pages at the end of the table.

An alternative solution would be to lower the vacuum delay settings before
starting the truncating phase, but this doesn't work very well in autovacuum
due to the autobalancing code (which can cause other processes to change our
cost delay settings).  This case could be considered in the balancing code, but
it is simpler this way.
2007-09-10 17:58:50 +00:00
Teodor Sigaev
4a78bd8a4d Improve page split in rtree emulation. Now if splitted result has
big misalignement, then it tries to split page basing on distribution
of boxe's centers.

Per report from  Dolafi, Tom <dolafit@janelia.hhmi.org>

 Backpatch is needed, changes doesn't affect on-disk storage.
2007-09-07 17:04:46 +00:00
Teodor Sigaev
eb22ca6f9f Fix indefinit loop in rank_cd for some corner queries.
Per Daniele Varrazzo <piro@develer.com> bug report.
2007-09-07 16:26:59 +00:00
Tom Lane
7cee08efee Apply a band-aid fix for the problem that 8.2 and up completely misestimate
the number of rows likely to be produced by a query such as
	SELECT * FROM t1 LEFT JOIN t2 USING (key) WHERE t2.key IS NULL;
What this is doing is selecting for t1 rows with no match in t2, and thus
it may produce a significant number of rows even if the t2.key table column
contains no nulls at all.  8.2 thinks the table column's null fraction is
relevant and thus may estimate no rows out, which results in terrible plans
if there are more joins above this one.  A proper fix for this will involve
passing much more information about the context of a clause to the selectivity
estimator functions than we ever have.  There's no time left to write such a
patch for 8.3, and it wouldn't be back-patchable into 8.2 anyway.  Instead,
put in an ad-hoc test to defeat the normal table-stats-based estimation when
an IS NULL test is evaluated at an outer join, and just use a constant
estimate instead --- I went with 0.5 for lack of a better idea.  This won't
catch every case but it will catch the typical ways of writing such queries,
and it seems unlikely to make things worse for other queries.
2007-08-31 23:35:30 +00:00
Tom Lane
2e5e715770 Extend whole-row Var evaluation to cope with the case that the sub-plan
generating the tuples has resjunk output columns.  This is not possible for
simple table scans but can happen when evaluating a whole-row Var for a view.
Per example from Patryk Kordylewski.  The problem exists back to 8.0 but
I'm not going to risk back-patching further than 8.2 because of the many
changes in this area.
2007-08-31 18:33:47 +00:00
Tom Lane
e257e6095f Rewrite make_outerjoininfo's construction of min_lefthand and min_righthand
sets for outer joins, in the light of bug #3588 and additional thought and
experimentation.  The original methodology was fatally flawed for nests of
more than two outer joins: it got the relationships between adjacent joins
right, but didn't always come to the right conclusions about whether a join
could be interchanged with one two or more levels below it.  This was largely
caused by a mistaken idea that we should use the min_lefthand + min_righthand
sets of a sub-join as the minimum left or right input set of an upper join
when we conclude that the sub-join can't commute with the upper one.  If
there's a still-lower join that the sub-join *can* commute with, this method
led us to think that that one could commute with the topmost join; which it
can't.  Another problem (not directly connected to bug #3588) was that
make_outerjoininfo's processing-order-dependent method for enforcing outer
join identity #3 didn't work right: if we decided that join A could safely
commute with lower join B, we dropped all information about sub-joins under B
that join A could perhaps not safely commute with, because we removed B's
entire min_righthand from A's.

To fix, make an explicit computation of all inner join combinations that occur
below an outer join, and add to that the full syntactic relsets of any lower
outer joins that we determine it can't commute with.  This method gives much
more direct enforcement of the outer join rearrangement identities, and it
turns out not to cost a lot of additional bookkeeping.

Thanks to Richard Harris for the bug report and test case.
2007-08-31 01:44:14 +00:00
Tom Lane
ed2af67b7a Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(),
the wrong variable's value was printed, and so the message made no sense.
Clean up a couple other coding infelicities while at it.
2007-08-29 16:31:45 +00:00
Michael Meskes
4eaf0e311d Fixed bug in Informix define handling. 2007-08-29 13:58:34 +00:00
Tom Lane
acb6631041 Restrict pgstattuple functions to superusers. While the only one that's
really a glaring security hole is bt_page_items, there's not a very good
use-case for letting ordinary users use 'em, either.
2007-08-28 23:11:12 +00:00
Tom Lane
10f4362255 Fix brain fade in DefineIndex(): it was continuing to access the table's
relcache entry after having heap_close'd it.  This could lead to misbehavior
if a relcache flush wiped out the cache entry meanwhile.  In 8.2 there is a
very real risk of CREATE INDEX CONCURRENTLY using the wrong relid for locking
and waiting purposes.  I think the bug is only cosmetic in 8.0 and 8.1,
because their transgression is limited to using RelationGetRelationName(rel)
in an ereport message immediately after heap_close, and there's no way (except
with special debugging options) for a cache flush to occur in that interval.
Not quite sure that it's cosmetic in 7.4, but seems best to patch anyway.

Found by trying to run the regression tests with CLOBBER_CACHE_ALWAYS enabled.
Maybe we should try to do that on a regular basis --- it's awfully slow,
but perhaps some fast buildfarm machine could do it once in awhile.
2007-08-25 19:08:25 +00:00
Tom Lane
f94c9dbf22 Fix combo_decrypt() to throw an error for zero-length input when using a
padded encryption scheme.  Formerly it would try to access res[(unsigned) -1],
which resulted in core dumps on 64-bit machines, and was certainly trouble
waiting to happen on 32-bit machines (though in at least the known case
it was harmless because that byte would be overwritten after return).
Per report from Ken Colson; fix by Marko Kreen.
2007-08-23 16:15:57 +00:00