Commit Graph

24054 Commits

Author SHA1 Message Date
Tom Lane
01d9754bd9 Repair oversight in creation of "append relations": we should set up
rel->tuples as well as rel->rows, since some estimation functions expect both
to be valid in every baserel.  Per report from Dave Dutcher.
2007-01-28 18:50:48 +00:00
Tom Lane
8a114e0031 Fix up plpgsql's "simple expression" evaluation mechanism so that it behaves
safely in the presence of subtransactions.  To ensure that any ExprContext
shutdown callbacks are called at the right times, we have to have a separate
EState for each level of subtransaction.  Per "TupleDesc reference leak" bug
report from Stefan Kaltenbrunner.

Although I'm convinced the code is wrong as far back as 8.0, it doesn't seem
that there are any ways for the problem to really manifest before 8.2: AFAICS,
8.0 and 8.1 only use the ExprContextCallback mechanism to handle set-returning
functions, which cannot usefully be executed in a "simple expression" anyway.
Hence, no backpatch before 8.2 --- the risk of unforeseen breakage seems
to outweigh the chance of fixing something.
2007-01-28 16:15:58 +00:00
Tom Lane
e96164dd71 Dept of second thoughts: the IQ of estimate_array_length() needs to be
kept on par with that of scalararraysel(), else estimates that should
track might not.  Hence teach it about binary-compatible cases, too.
2007-01-28 02:53:42 +00:00
Tom Lane
ff3c2e4e46 Fix scalararraysel() to cope with binary-compatible cases, such as text[]
versus varchar[].  This oversight probably explains Ryan Holmes' recent
complaint --- he was getting a generic selectivity estimate instead of
anything intelligent.
2007-01-28 01:37:45 +00:00
Tom Lane
223cd82c1d Correct an old logic error in btree page splitting: when considering a split
exactly at the point where we need to insert a new item, the calculation used
the wrong size for the "high key" of the new left page.  This could lead to
choosing an unworkable split, resulting in "PANIC: failed to add item to the
left sibling" (or "right sibling") failure.  Although this bug has been there
a long time, it's very difficult to trigger a failure before 8.2, since there
was generally a lot of free space on both sides of a chosen split.  In 8.2,
where the user-selected fill factor determines how much free space the code
tries to leave, an unworkable split is much more likely.  Report by Joe
Conway, diagnosis and fix by Heikki Linnakangas.
2007-01-27 20:53:36 +00:00
Tom Lane
cb476c1ec3 Back-port changes of Jan 16 and 17 to "revoke" pending fsync requests during
DROP TABLE and DROP DATABASE.  Should prevent unexpected "permission denied"
failures on Windows, and is cleaner on other platforms too since we no longer
have to take it on faith that ENOENT is okay during an fsync attempt.

Patched as far back as 8.1; per recent discussion I think we are not going
to worry about Windows-specific issues in 8.0 anymore.
2007-01-27 20:15:47 +00:00
Tom Lane
043fcd6616 On Windows, use pgwin32_waitforsinglesocket() instead of select() to wait for
input in the stats collector.  Our select() emulation is apparently buggy
for UDP sockets :-(.  This should resolve problems with stats collection
(and hence autovacuum) failing under more than minimal load.  Diagnosis
and patch by Magnus Hagander.

Patch probably needs to be back-ported to 8.1 and 8.0, but first let's
see if it makes the buildfarm happy...
2007-01-26 20:07:01 +00:00
Bruce Momjian
ebe2830613 Properly detoast access to bytea field pg_trigger.tgargs. Old code
might cause server crash.

Backpatch to 8.2.X.
2007-01-25 04:17:56 +00:00
Tom Lane
4e978c4e27 Get pg_utf_mblen(), pg_utf2wchar_with_len(), and utf2ucs() all on the same
page about the maximum UTF8 sequence length we support (4 bytes since 8.1,
3 before that).  pg_utf2wchar_with_len never got updated to support 4-byte
characters at all, and in any case had a buffer-overrun risk in that it
could produce multiple pg_wchars from what mblen claims to be just one UTF8
character.  The only reason we don't have a major security hole is that most
callers allocate worst-case output buffers; the sole exception in released
versions appears to be pre-8.2 iwchareq() (ie, ILIKE), which can be crashed
due to zeroing out its return address --- but AFAICS that can't be exploited
for anything more than a crash, due to inability to control what gets written
there.  Per report from James Russell and Michael Fuhr.

Pre-8.1 the risk is much less, but I still think pg_utf2wchar_with_len's
behavior given an incomplete final character risks buffer overrun, so
back-patch that logic change anyway.

This patch also makes sure that UTF8 sequences exceeding the supported
length (whichever it is) are consistently treated as error cases, rather
than being treated like a valid shorter sequence in some places.
2007-01-24 17:12:23 +00:00
Tom Lane
5edf3429ad Relax an Assert() that has been found to be too strict in some situations
involving unions of types having typmods.  Variants of the failure are known
to occur in 8.1 and up; not sure if it's possible in 8.0 and 7.4, but since
the code exists that far back, I'll just patch 'em all.  Per report from
Brian Hurt.
2007-01-24 01:25:51 +00:00
Bruce Momjian
9352ed9a9c Add documentation of memory and time units to postgresql.conf.
Backpatch to 8.2.X for new initdbs.
2007-01-20 21:42:06 +00:00
Bruce Momjian
891b9fbba5 Update documentation about postgresqlconf to mention default units that
match the postgresql.conf file.  Also add units to descriptions that
lacked them.  Wording improvements.  Mention pg_settings.unit as the way
to find the default units for setting.

Backpatch to 8.2.X.
2007-01-20 21:30:35 +00:00
Bruce Momjian
55391ab6a7 Document that to remove template1, datistemplate must be 'false'.
Backpatch to 8.2.
2007-01-20 15:43:58 +00:00
Tom Lane
09f4894154 Fix incorrect permissions check in information_schema.key_column_usage view:
it was checking a pg_constraint OID instead of pg_class OID, resulting in
"relation with OID nnnnn does not exist" failures for anyone who wasn't
owner of the table being examined.  Per bug #2848 from Laurence Rowe.

Note: for existing 8.2 installations a simple version update won't fix this;
the easiest fix is to CREATE OR REPLACE this view with the corrected
definition.
2007-01-16 18:32:32 +00:00
Neil Conway
20fe8b033a Correct a minor inaccuracy in the pg_dumpall reference page: -g dumps
roles and tablespaces, no longer users and groups. Per Dave Page.

Backport to 8.2 and 8.1.
2007-01-15 17:22:48 +00:00
Teodor Sigaev
35466cff0a Fix localization support for multibyte encoding and C locale.
Slightly reworked patch from Tatsuo Ishii
2007-01-15 15:16:11 +00:00
Tom Lane
65fe39ee0a Fix handling of CC (century) format spec in to_date/to_char. According to
standard convention the 21st century runs from 2001-2100, not 2000-2099,
so make it work like that.  Per bug #2885 from Akio Iwaasa.

Backpatch to 8.2, but no further, since this is really a definitional
change; users of older branches are probably more interested in stability.
2007-01-12 23:35:04 +00:00
Tom Lane
c483632d25 Fix a performance problem in databases with large numbers of tables
(or other types of pg_class entry): the function pgstat_vacuum_tabstat,
invoked during VACUUM startup, had runtime proportional to the number of
stats table entries times the number of pg_class rows; in other words
O(N^2) if the stats collector's information is reasonably complete.
Replace list searching with a hash table to bring it back to O(N)
behavior.  Per report from kim at myemma.com.

Back-patch as far as 8.1; 8.0 and before use different coding here.
2007-01-11 23:06:09 +00:00
Bruce Momjian
6a59778360 Allow Borland CC to compile libpq and psql.
Backpatch to 8.2.X.

L Bayuk
2007-01-11 02:40:12 +00:00
Tatsuo Ishii
9c505e484c Backport patch.
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.
2007-01-10 01:20:10 +00:00
Tom Lane
757dfd6327 Tweak joinlist creation to avoid generating useless one-element subproblems
when collapsing of JOIN trees is stopped by join_collapse_limit.  For instance
a list of 11 LEFT JOINs with limit 8 now produces something like
	((1 2 3 4 5 6 7 8) 9 10 11 12)
instead of
	(((1 2 3 4 5 6 7 8) (9)) 10 11 12)
The latter structure is really only required for a FULL JOIN.
Noted while studying an example from Shane Ambler.
2007-01-08 16:47:35 +00:00
Tom Lane
9c1443e66f Remove cost_hashjoin's very ancient hack to discourage (once, entirely forbid)
hash joins with the estimated-larger relation on the inside.  There are
several cases where doing that makes perfect sense, and in cases where it
doesn't, the regular cost computation really ought to be able to figure that
out.  Make some marginal tweaks in said computation to try to get results
approximating reality a bit better.  Per an example from Shane Ambler.

Also, fix an oversight in the original patch to add seq_page_cost: the costs
of spilling a hash join to disk should be scaled by seq_page_cost.
2007-01-08 16:09:31 +00:00
Tom Lane
2054724c08 Fix oversight in handling of row-comparison index keys: if the row comparison
doesn't exactly match the index, we may have to change our initial positioning
strategy.  For example, given an index on (f1,f2,f3) and a WHERE condition
"ROW(f1,f3) > ROW(2,3)", the code extracted the initial-positioning condition
"f1 > 2", which is wrong ... it has to be "f1 >= 2", else some rows matching
the WHERE condition may fail to be returned.

Applying patch to 8.2 only --- I'll fix it in HEAD later as part of the
planned index improvements (reverse-sort and NULLS FIRST/LAST work).
2007-01-07 01:56:24 +00:00
Tom Lane
79a0a57581 Fix filtered_base_yylex() to save and restore base_yylval and base_yylloc
properly when doing a lookahead.  The lack of this was causing various
interesting misbehaviors when one tries to use "with" as a plain identifier.
2007-01-06 19:14:27 +00:00
PostgreSQL Daemon
78c795d4e5 tag configure 2007-01-06 05:02:26 +00:00
Tom Lane
acb01484d6 Minor copy-editing for release note updates. 2007-01-05 22:34:46 +00:00
Bruce Momjian
e82da29033 Update Japanese FAQ. 2007-01-05 20:57:17 +00:00
Bruce Momjian
4290bb4e0f Stamp release 8.2.1. Update FAQs. 2007-01-05 20:55:29 +00:00
Bruce Momjian
d6c8cdcceb Create release notes for release 8.2.1. 2007-01-05 20:05:47 +00:00
Tom Lane
2ca07b0c4a Add missing reference to pg_shdescription. Greg Mullane 2007-01-05 01:19:04 +00:00
Tom Lane
34615ce73d Tweak pg_dumpall to add GRANT CONNECT ON DATABASE ... TO PUBLIC when dumping
database privileges from a pre-8.2 server.  This ensures that the reloaded
database will maintain the same behavior it had in the previous installation,
ie, everybody has connect privilege.  Per gripe from L Bayuk.
2007-01-04 17:49:42 +00:00
Tom Lane
4fe7a6b51e Fix erroneous implementation of -s in postmaster.c (the switch doesn't take
an optarg).  Add some comments noting that code in three different files has
to be kept in sync.  Fix erroneous description of -S switch (it sets work_mem
not silent_mode), and do some light copy-editing elsewhere in postgres-ref.
2007-01-04 00:58:01 +00:00
Tom Lane
f532a22a8f Fix regex_fixed_prefix() to cope reasonably well with regex patterns of the
form '^(foo)$'.  Before, these could never be optimized into indexscans.
The recent changes to make psql and pg_dump generate such patterns (for \d
commands and -t and related switches, respectively) therefore represented
a big performance hit for people with large pg_class catalogs, as seen in
recent gripe from Erik Jones.  While at it, be more paranoid about
case-sensitivity checking in multibyte encodings, and fix some other
corner cases in which a regex might be interpreted too liberally.
2007-01-03 22:39:35 +00:00
Tom Lane
32d029573d Add a defense to prevent core dumps if 8.2 version of rank_cd() is used with
the 8.1 SQL function definition for it.  Per report from Rajesh Kumar Mallah,
such a DBA error doesn't seem at all improbable, and the cost of checking for
it is not very high compared to the cost of running this function.  (It would
have been better to change the C name of the function so it wouldn't be called
by the old SQL definition, but it's too late for that now in the 8.2 branch.)
2006-12-28 01:09:04 +00:00
Tom Lane
46d90d6b52 Revert exports.list change pending closer study. 2006-12-28 00:01:12 +00:00
Tom Lane
37dc08bff0 Use a more backward-compatible syntax for exports.list on Linux.
Per Thorkil Olesen.
2006-12-27 23:53:21 +00:00
Tom Lane
1e78ea0ffe Modify local buffer management to request memory for local buffers in blocks
of increasing size, instead of one at a time.  This reduces the memory
management overhead when num_temp_buffers is large: in the previous coding
we would actually waste 50% of the space used for temp buffers, because aset.c
would round the individual requests up to 16K.  Problem noted while studying
a performance issue reported by Steven Flatt.

Back-patch as far as 8.1 --- older versions used few enough local buffers
that the issue isn't significant for them.
2006-12-27 22:31:59 +00:00
Tom Lane
38b72135c9 Print combining characters (those reported as having zero width by
PQdsplen()) normally, instead of replacing them by \uXXXX sequences.
Assume that they in fact occupy zero screen space for formatting purposes.
Per gripe from Michael Fuhr and ensuing discussion.
2006-12-27 19:45:51 +00:00
Tom Lane
094ccd1ca3 Use FROM clause in example UPDATE commands where appropriate. Also
remove long-obsolete statement that there isn't a check for infinite
recursion in view rules.
2006-12-27 16:07:42 +00:00
Tom Lane
66a7fd2ec1 Fix broken markup. 2006-12-27 16:04:47 +00:00
Tom Lane
4a1bffa066 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.
2006-12-26 21:37:28 +00:00
Tom Lane
85a373b1f0 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.
2006-12-26 19:26:56 +00:00
Tom Lane
b85a4cda83 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.
2006-12-26 16:56:22 +00:00
Teodor Sigaev
5ceb508422 Fix memory reallocation condition 2006-12-26 14:55:00 +00:00
Tom Lane
3b1645d119 Make HISTCONTROL=ignoredups work again (broken by misordering of
operations during recent code refactoring).  Per bug #2840 from Ned Crigler.
2006-12-24 19:14:41 +00:00
Teodor Sigaev
593d020ff6 Fix convertion for 'PFX flag N num' 2006-12-21 17:35:44 +00:00
Bruce Momjian
d686dccdb8 Remove completed TODO item about xid wrap-around from 8.2.X. 2006-12-19 21:58:43 +00:00
Tom Lane
14bdb023cc 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.
2006-12-15 18:42:35 +00:00
Tom Lane
4f554024a8 Put JST back into the default set of timezone abbreviations;
was removed in an unexplainable moment of brain fade.
2006-12-15 16:54:56 +00:00
Bruce Momjian
880dae5f2b Back out double-run of PDF/PS output. Requires building bookindex.sgml
properly.

Remove SGML docs about openjade performance patch, and instead add
comment in style sheet where indenting code is commented out.

Backpatch to 8.2.X.
2006-12-15 16:50:10 +00:00