Tom Lane [Tue, 26 Dec 2006 21:37:20 +0000 (21:37 +0000)]
Fix failure due to accessing an already-freed tuple descriptor in a plan
involving HashAggregate over SubqueryScan (this is the known case, there
may well be more). The bug is only latent in releases before 8.2 since they
didn't try to access tupletable slots' descriptors during ExecDropTupleTable.
The least bogus fix seems to be to make subqueries share the parent query's
memory context, so that tupdescs they create will have the same lifespan as
those of the parent query. There are comments in the code envisioning going
even further by not having a separate child EState at all, but that will
require rethinking executor access to range tables, which I don't want to
tackle right now. Per bug report from Jean-Pierre Pelletier.
Tom Lane [Tue, 26 Dec 2006 19:26:46 +0000 (19:26 +0000)]
Repair bug #2839: the various ExecReScan functions need to reset
ps_TupFromTlist in plan nodes that make use of it. This was being done
correctly in join nodes and Result nodes but not in any relation-scan nodes.
Bug would lead to bogus results if a set-returning function appeared in the
targetlist of a subquery that could be rescanned after partial execution,
for example a subquery within EXISTS(). Bug has been around forever :-(
... surprising it wasn't reported before.
Tom Lane [Tue, 26 Dec 2006 16:56:18 +0000 (16:56 +0000)]
Repair bug #2836: SPI_execute_plan returned zero if none of the querytrees
were marked canSetTag. While it's certainly correct to return the result
of the last one that is marked canSetTag, it's less clear what to do when
none of them are. Since plpgsql will complain if zero is returned, the
8.2.0 behavior isn't good. I've fixed it to restore the prior behavior of
returning the physically last query's result code when there are no
canSetTag queries.
Tatsuo Ishii [Tue, 26 Dec 2006 01:02:05 +0000 (01:02 +0000)]
Call srandom() instead of srand().
pgbench calls random() later, so it should have called srandom().
On most platforms except Windows srandom() is actually identical
to srand(), so the bug only bites Windows users.
per bug report from Akio Ishida.
Tom Lane [Sun, 24 Dec 2006 18:25:58 +0000 (18:25 +0000)]
Bring some order and sanity to error handling in the xml patch.
Use a TRY block instead of (inadequate) ad-hoc coding to ensure that
libxml is cleaned up after a failure. Report the intended SQLCODE
instead of defaulting to XX000. Avoid risking use of a dangling
pointer by keeping the persistent error buffer in TopMemoryContext.
Be less trusting that error messages don't contain %.
This patch doesn't do anything about changing the way the messages
are put together --- this is just about mechanism.
Tom Lane [Sun, 24 Dec 2006 00:57:48 +0000 (00:57 +0000)]
Fix machine-dependent crash in sqlchar_to_unicode(). Get rid of
bletcherous and unsafe manipulation of global encoding setting.
Clean up libxml reporting mechanism a bit (it still looks like a
dangling-pointer crash waiting to happen, though, not to mention
being far less than sane from a localization standpoint).
Tom Lane [Sun, 24 Dec 2006 00:29:20 +0000 (00:29 +0000)]
Code review for XML patch. Instill a bit of sanity in the location of
the XmlExpr code in various lists, use a representation that has some hope
of reverse-listing correctly (though it's still a de-escaping function
shy of correctness), generally try to make it look more like Postgres
coding conventions.
Bruce Momjian [Sat, 23 Dec 2006 00:52:40 +0000 (00:52 +0000)]
For GUC values, check for partial string matches on 'on' and 'off', but
require at least two characters for uniqueness. This now matches the
behavior of other boolean strings we support, per report from Gurjeet
Singh.
Tom Lane [Sat, 23 Dec 2006 00:43:13 +0000 (00:43 +0000)]
Restructure operator classes to allow improved handling of cross-data-type
cases. Operator classes now exist within "operator families". While most
families are equivalent to a single class, related classes can be grouped
into one family to represent the fact that they are semantically compatible.
Cross-type operators are now naturally adjunct parts of a family, without
having to wedge them into a particular opclass as we had done originally.
This commit restructures the catalogs and cleans up enough of the fallout so
that everything still works at least as well as before, but most of the work
needed to actually improve the planner's behavior will come later. Also,
there are not yet CREATE/DROP/ALTER OPERATOR FAMILY commands; the only way
to create a new family right now is to allow CREATE OPERATOR CLASS to make
one by default. I owe some more documentation work, too. But that can all
be done in smaller pieces once this infrastructure is in place.
Tom Lane [Mon, 18 Dec 2006 18:56:29 +0000 (18:56 +0000)]
Set pg_am.amstrategies to zero for index AMs that don't have fixed
operator strategy numbers, ie, GiST and GIN. This is almost cosmetic
enough to not need a catversion bump, but since the opr_sanity regression
test has to change in sync with the catalog entry, I figured I'd better
do one.
Tom Lane [Fri, 15 Dec 2006 18:42:26 +0000 (18:42 +0000)]
Fix some planner bugs exposed by reports from Arjen van der Meijden. These
are all in new-in-8.2 logic associated with indexability of ScalarArrayOpExpr
(IN-clauses) or amortization of indexscan costs across repeated indexscans
on the inside of a nestloop. In particular:
Fix some logic errors in the estimation for multiple scans induced by a
ScalarArrayOpExpr indexqual.
Include a small cost component in bitmap index scans to reflect the costs of
manipulating the bitmap itself; this is mainly to prevent a bitmap scan from
appearing to have the same cost as a plain indexscan for fetching a single
tuple.
Also add a per-index-scan-startup CPU cost component; while prior releases
were clearly too pessimistic about the cost of repeated indexscans, the
original 8.2 coding allowed the cost of an indexscan to effectively go to zero
if repeated often enough, which is overly optimistic.
Pay some attention to index correlation when estimating costs for a nestloop
inner indexscan: this is significant when the plan fetches multiple heap
tuples per iteration, since high correlation means those tuples are probably
on the same or adjacent heap pages.
Bruce Momjian [Fri, 15 Dec 2006 15:40:52 +0000 (15:40 +0000)]
TODO item not wanted:
>
> * Embedded server (not wanted)
>
> While PostgreSQL clients runs fine limited-resource environments, the
> server requires multiple processes and a stable pool of resources to
> run reliabily and efficiently. Stripping down the PostgreSQL server
> to run in the same process address space as the client application
> would add too much complexity and failure cases.
Bruce Momjian [Fri, 15 Dec 2006 13:28:54 +0000 (13:28 +0000)]
Link to summary XML email, rather than thread top:
< * Consider changing documentation from SGML to XML
> * Consider changing documentation format from SGML to XML
< http://archives.postgresql.org/pgsql-docs/2006-12/msg00033.php
> http://archives.postgresql.org/pgsql-docs/2006-12/msg00152.php
Bruce Momjian [Tue, 12 Dec 2006 22:31:19 +0000 (22:31 +0000)]
Update entry:
< * Have EXPLAIN ANALYZE highlight poor optimizer estimates
> * Have EXPLAIN ANALYZE issue NOTICE messages when the estimated and
> actual row counts differ by a specified percentage
Tom Lane [Tue, 12 Dec 2006 21:31:02 +0000 (21:31 +0000)]
Fix planner to do the right thing when a degenerate outer join (one whose
joinclause doesn't use any outer-side vars) requires a "bushy" plan to be
created. The normal heuristic to avoid joins with no joinclause has to be
overridden in that case. Problem is new in 8.2; before that we forced the
outer join order anyway. Per example from Teodor.
Tom Lane [Sun, 10 Dec 2006 22:13:27 +0000 (22:13 +0000)]
Add a paramtypmod field to Param nodes. This is dead weight for Params
representing externally-supplied values, since the APIs that carry such
values only specify type not typmod. However, for PARAM_SUBLINK Params
it is handy to carry the typmod of the sublink's output column. This
is a much cleaner solution for the recently reported 'could not find
pathkey item to sort' and 'failed to find unique expression in subplan
tlist' bugs than my original 8.2-compatible patch. Besides, someday we
might want to support typmods for external parameters ...
Tom Lane [Fri, 8 Dec 2006 19:50:53 +0000 (19:50 +0000)]
Remove the logId/logSeg fields from pg_control, because they are not needed
in normal operation, and we can avoid rewriting pg_control at every log
segment switch if we don't insist that these values be valid. Reducing
the number of pg_control updates is a good idea for both performance and
reliability. It does make pg_resetxlog's life a bit harder, but that seems
a good tradeoff; and anyway the change to pg_resetxlog amounts to automating
something people formerly needed to do by hand, namely look at the existing
pg_xlog files to make sure the new WAL start point was past them.
In passing, change the wording of xlog.c's "database system was interrupted"
messages: describe the pg_control timestamp as "last known up at" rather than
implying it is the exact time of service interruption. With this change the
timestamp will generally be the time of the last checkpoint, which could be
many minutes before the failure; and we've already seen indications that
people tend to misinterpret the old wording.
initdb forced due to change in pg_control layout. Simon Riggs and Tom Lane
Tom Lane [Fri, 8 Dec 2006 00:40:27 +0000 (00:40 +0000)]
Avoid double free of _SPI_current->tuptable. AtEOSubXact_SPI() now tries to
release it in a subtransaction abort, but this neglects possibility that
someone outside SPI already did. Fix is for spi.c to forget about a tuptable
as soon as it's handed it back to the caller.
Per bug #2817 from Michael Andreen.
Tom Lane [Thu, 7 Dec 2006 19:33:40 +0000 (19:33 +0000)]
Repair incorrect placement of WHERE clauses when there are multiple,
rearrangeable outer joins and the WHERE clause is non-strict and mentions
only nullable-side relations. New bug in 8.2, caused by new logic to allow
rearranging outer joins. Per bug #2807 from Ross Cohen; thanks to Jeff
Davis for producing a usable test case.
Tom Lane [Wed, 6 Dec 2006 19:40:01 +0000 (19:40 +0000)]
Fix planning of SubLinks to ensure that Vars generated from transformation of
a sublink's test expression have the correct vartypmod, rather than defaulting
to -1. There's at least one place where this is important because we're
expecting these Vars to be exactly equal() to those appearing in the subplan
itself. This is a pretty klugy solution --- it would likely be cleaner to
change Param nodes to include a typmod field --- but we can't do that in the
already-released 8.2 branch.
Per bug report from Hubert Fongarnand.
Neil Conway [Wed, 6 Dec 2006 18:06:48 +0000 (18:06 +0000)]
Add a txn_start column to pg_stat_activity. This makes it easier to
identify long-running transactions. Since we already need to record
the transaction-start time (e.g. for now()), we don't need any
additional system calls to report this information.
Neil Conway [Wed, 6 Dec 2006 17:35:49 +0000 (17:35 +0000)]
Various improvements to the GUC description strings. Punctuate and
capitalize the strings like sentences. Remove unnecessarily
specific descriptions of the units used by GUC variables, since
we now allow any reasonable unit to be specified.
Tom Lane [Mon, 4 Dec 2006 02:06:55 +0000 (02:06 +0000)]
Refactor ExecGetJunkAttribute to avoid searching for junk attributes
by name on each and every row processed. Profiling suggests this may
buy a percent or two for simple UPDATE scenarios, which isn't huge,
but when it's so easy to get ...
Tom Lane [Sun, 3 Dec 2006 21:40:07 +0000 (21:40 +0000)]
Fix LIMIT/OFFSET for null limit values. This worked before 8.2 but was broken
by the change to make limit values int8 instead of int4. (Specifically, you
can do DatumGetInt32 safely on a null value, but not DatumGetInt64.) Per
bug #2803 from Greg Johnson.
Tom Lane [Fri, 1 Dec 2006 21:17:51 +0000 (21:17 +0000)]
Some more supported-platforms updates: buildfarm hare is alive again,
and penguin reported in recently enough to justify the assumption that
we haven't broken ARM support in 8.2.
Tom Lane [Fri, 1 Dec 2006 20:49:53 +0000 (20:49 +0000)]
Document the recently-understood hazard that a rollback can release row-level
locks that logically should not be released, because when a subtransaction
overwrites XMAX all knowledge of the previous lock state is lost. It seems
unlikely that we will be able to fix this before 8.3...
Tom Lane [Fri, 1 Dec 2006 19:55:28 +0000 (19:55 +0000)]
Make the bgwriter's error recovery path do smgrcloseall(). On Windows this
should allow delete-pending files to actually go away, and thereby work
around the various complaints we've seen about 'permission denied'
errors in such cases. Should be reasonably harmless in any case...
Tom Lane [Fri, 1 Dec 2006 01:04:36 +0000 (01:04 +0000)]
Adjust the description of locking to clarify that locks held by a
subtransaction are released if the subtransaction aborts --- in user-level
terminology, this means either rolling back to a savepoint or escaping from
a plpgsql exception block. Per recent suggestion from Simon.