summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2007-09-07Improve page split in rtree emulation. Now if splitted result hasTeodor Sigaev
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-08-31Apply a band-aid fix for the problem that 8.2 and up completely misestimateTom Lane
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-31Extend whole-row Var evaluation to cope with the case that the sub-planTom Lane
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-31Rewrite make_outerjoininfo's construction of min_lefthand and min_righthandTom Lane
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-29Fix aboriginal bug in _tarAddFile(): when complaining that the amount of dataTom Lane
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-29Fixed bug in Informix define handling.Michael Meskes
2007-08-25Fix brain fade in DefineIndex(): it was continuing to access the table'sTom Lane
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-21Fix potential access-off-the-end-of-memory in varbit_out(): it fetched theTom Lane
byte after the last full byte of the bit array, regardless of whether that byte was part of the valid data or not. Found by buildfarm testing. Thanks to Stefan Kaltenbrunner for nailing down the cause.
2007-08-15Repair problems occurring when multiple RI updates have to be done to the sameTom Lane
row within one query: we were firing check triggers before all the updates were done, leading to bogus failures. Fix by making the triggers queued by an RI update go at the end of the outer query's trigger event list, thereby effectively making the processing "breadth-first". This was indeed how it worked pre-8.0, so the bug does not occur in the 7.x branches. Per report from Pavel Stehule.
2007-08-10Fix uninitialized-memory bug in plpython proargnames patch. Per bug #3523Tom Lane
2007-08-10Fix unintended change of output format for createlang/droplang -l. MissedTom Lane
these uses of printQuery() in FETCH_COUNT patch a year ago :-(. Per report from Tomoaki Sato.
2007-08-08Fix a gradual memory leak in ExecReScanAgg(). Because the aggregationNeil Conway
hash table is allocated in a child context of the agg node's memory context, MemoryContextReset() will reset but *not* delete the child context. Since ExecReScanAgg() proceeds to build a new hash table from scratch (in a new sub-context), this results in leaking the header for the previous memory context. Therefore, use MemoryContextResetAndDeleteChildren() instead. Credit: My colleague Sailesh Krishnamurthy at Truviso for isolating the cause of the leak.
2007-08-06Fix pg_restore to guard against unexpected EOF while reading an archive file.Tom Lane
Per report and partial patch from Chad Wagner.
2007-08-04Suppress time zone name (%Z) when logging timestamps in xlog.c startupTom Lane
on Windows. This is yet another manifestation of the problem that Windows returns time zone names that may be in a different encoding than we are using. I've put a better solution in HEAD, but the back branches need a simple patch. Per report from Hiroshi Saito.
2007-08-02Make sure syslogPipe runs in binary mode on Windows to avoid corrupting the ↵Andrew Dunstan
pipe chunking protocol. Backport to 8.0
2007-08-02Fix a memory leak in tuplestore_end(). Unlikely to be significant duringNeil Conway
normal operation, but tuplestore_end() ought to do what it claims to do.
2007-07-31Fix a bug in the original implementation of redundant-join-clause removal:Tom Lane
clauses in which one side or the other references both sides of the join cannot be removed as redundant, because that expression won't have been constrained below the join. Per report from Sergey Burladyan.
2007-07-31Fix security definer functions with polymorphic arguments. This case hasTom Lane
never worked because fmgr_security_definer() neglected to pass the fn_expr information through. Per report from Viatcheslav Kalinin.
2007-07-24Fix predicate-proving logic to cope with binary-compatibility cases whenTom Lane
checking whether an IS NULL/IS NOT NULL clause is implied or refuted by a strict function. Per example from Dawid Kuroczko. Backpatch to 8.2 since this is arguably a performance bug.
2007-07-23The correct min buffer size isMagnus Hagander
INITIAL_EXPBUFFER_SIZE, not PQERRORMSG_LENGTH. Backpatch only, the proper fix in HEAD is to use PQExpBuffers everywhere.
2007-07-21Fix elog.c to avoid infinite recursion (leading to backend crash) whenTom Lane
log_min_error_statement is active and there is some problem in logging the current query string; for example, that it's too long to include in the log message without running out of memory. This problem has existed since the log_min_error_statement feature was introduced. No doubt the reason it wasn't detected long ago is that 8.2 is the first release that defaults log_min_error_statement to less than PANIC level. Per report from Bill Moran.
2007-07-20Fix WAL replay of truncate operations to cope with the possibility that theTom Lane
truncated relation was deleted later in the WAL sequence. Since replay normally auto-creates a relation upon its first reference by a WAL log entry, failure is seen only if the truncate entry happens to be the first reference after the checkpoint we're restarting from; which is a pretty unusual case but of course not impossible. Fix by making truncate entries auto-create like the other ones do. Per report and test case from Dharmendra Goyal.
2007-07-19Make replace(), split_part(), and string_to_array() behave somewhat sanelyTom Lane
when handed an invalidly-encoded pattern. The previous coding could get into an infinite loop if pg_mb2wchar_with_len() returned a zero-length string after we'd tested for nonempty pattern; which is exactly what it will do if the string consists only of an incomplete multibyte character. This led to either an out-of-memory error or a backend crash depending on platform. Per report from Wiktor Wodecki.
2007-07-19Only use the pipe chunking protocol if we know the syslogger shouldAndrew Dunstan
be catching stderr output, and we are not ourselves the syslogger. Otherwise, go directly to stderr. Bug noticed by Tom Lane. Backpatch as far as 8.0.
2007-07-18Fix an old thinko in SS_make_initplan_from_plan, which is used when optimizingTom Lane
a MIN or MAX aggregate call into an indexscan: the initplan is being made at the current query nesting level and so we shouldn't increment query_level. Though usually harmless, this mistake could lead to bogus "plan should not reference subplan's variable" failures on complex queries. Per bug report from David Sanchez i Gregori.
2007-07-17Fix incorrect optimization of foreign-key checks. When an UPDATE on theTom Lane
referencing table does not change the tuple's FK column(s), we don't bother to check the PK table since the constraint was presumably already valid. However, the check is still necessary if the tuple was inserted by our own transaction, since in that case the INSERT trigger will conclude it need not make the check (since its version of the tuple has been deleted). We got this right for simple cases, but not when the insert and update are in different subtransactions of the current top-level transaction; in such cases the FK check would never be made at all. (Hence, problem dates back to 8.0 when subtransactions were added --- it's actually the subtransaction version of a bug fixed in 7.3.5.) Fix, and add regression test cases. Report and fix by Affan Salman.
2007-07-17Fix outfuncs.c to dump A_Const nodes representing NULLs correctly. This hasTom Lane
been broken since forever, but was not noticed because people seldom look at raw parse trees. AFAIK, no impact on users except that debug_print_parse might fail; but patch it all the way back anyway. Per report from Jeff Ross.
2007-07-12Fix mistaken Assert in adjust_appendrel_attr_needed, per Greg Stark.Tom Lane
2007-07-12Fix freenig of names in Kerberos when using MIT - need to use theMagnus Hagander
free function provided in the Kerberos library. This fixes a very hard to track down heap corruption on windows when using debug runtimes.
2007-07-09Fix stddev_pop(numeric) and var_pop(numeric), which were incorrectly producingTom Lane
the same outputs as stddev_samp() and var_samp() respectively.
2007-07-08Remove the pgstat_drop_relation() call from smgr_internal_unlink(), becauseTom Lane
we don't know at that point which relation OID to tell pgstat to forget. The code was passing the relfilenode, which is incorrect, and could possibly cause some other relation's stats to be zeroed out. While we could try to clean this up, it seems much simpler and more reliable to let the next invocation of pgstat_vacuum_tabstat() fix things; which indeed is how it worked before I introduced the buggy code into 8.1.3 and later :-(. Problem noticed by Itagaki Takahiro, fix is per subsequent discussion.
2007-07-02- Fix the -w (wait) option to work in Windows service mode, per bug #3382.Magnus Hagander
- Prevent the -w option being passed to the postmaster. - Read the postmaster options file when starting as a Windows service. Dave Page
2007-07-02Fix failure to restart Postgres when Linux kernel returns EIDRM for shmctl().Tom Lane
This is a Linux kernel bug that apparently exists in every extant kernel version: sometimes shmctl() will fail with EIDRM when EINVAL is correct. We were assuming that EIDRM indicates a possible conflict with pre-existing backends, and refusing to start the postmaster when this happens. Fortunately, there does not seem to be any case where Linux can legitimately return EIDRM (it doesn't track shmem segments in a way that would allow that), so we can get away with just assuming that EIDRM means EINVAL on this platform. Per reports from Michael Fuhr and Jon Lapham --- it's a bit surprising we have not seen more reports, actually.
2007-07-01Avoid memory leakage when a series of subtransactions invoke AFTER triggersTom Lane
that are fired at end-of-statement (as is the normal case for foreign keys, for example). In this situation the per-subxact deferred trigger context is always empty when subtransaction exit is reached; so we could free it, but were not doing so, leading to an intratransaction leak of 8K or more per subtransaction. Per off-list example from Viatcheslav Kalinin subsequent to bug #3418 (his original bug report omitted a foreign key constraint needed to cause this leak). Back-patch to 8.2; prior versions were not using per-subxact contexts for deferred triggers, so did not have this leak.
2007-06-29Fix a passel of ancient bugs in to_char(), including two distinct bufferTom Lane
overruns (neither of which seem likely to be exploitable as security holes, fortunately, since the provoker can't control the data written). One of these is due to choosing to stomp on the output of a called function, which is bad news in any case; make it treat the called functions' results as read-only. Avoid some unnecessary palloc/pfree traffic too; it's not really helpful to free small temporary objects, and again this is presuming more than it ought to about the nature of the results of called functions. Per report from Patrick Welche and additional code-reading by Imad.
2007-06-28Fix incorrect tests for undef Perl values in some places in plperl.c.Tom Lane
The correct test for defined-ness is SvOK(sv), not anything involving SvTYPE. Per bug #3415 from Matt Taylor. Back-patch as far as 8.0; no apparent problem in 7.x.
2007-06-22In psql, when running a SELECT query using a cursor, flush the queryNeil Conway
output after each FETCH. This ensures that incremental results are available to clients that are executing long-running SELECT queries via the FETCH_COUNT feature.
2007-06-20transformColumnDefinition failed to complain aboutTom Lane
create table foo (bar int default null default 3); due to not thinking about the special-case handling of DEFAULT NULL. Problem noticed while investigating bug #3396.
2007-06-20CREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULTTom Lane
NULL and DefineDomain didn't. Bug goes all the way back to original coding of domains. Per bug #3396 from Sergey Burladyan.
2007-06-14Avoid having autovacuum run multiple ANALYZE commands in a single transaction,Alvaro Herrera
to prevent possible deadlock problems. Per request from Tom Lane.
2007-06-14Implement a chunking protocol for writes to the syslogger pipe, with messagesAndrew Dunstan
reassembled in the syslogger before writing to the log file. This prevents partial messages from being written, which mucks up log rotation, and messages from different backends being interleaved, which causes garbled logs. Backport as far as 8.0, where the syslogger was introduced. Tom Lane and Andrew Dunstan
2007-06-12Fix DecodeDateTime to allow timezone to appear before year. This hadTom Lane
historically worked in some but not all cases, but as of 8.2 it failed for all timezone formats. Fix, and add regression test cases to catch future regressions in this area. Per gripe from Adam Witney.
2007-06-09Allow numeric_fac() to be interrupted, since it can take quite a while forTom Lane
large inputs. Also cause it to error out immediately if the result will overflow, instead of grinding through a lot of calculation first. Per gripe from Jim Nasby.
2007-06-07Avoid losing track of data for shared tables in pgstats. Report by MichaelAlvaro Herrera
Fuhr, patch from Tom Lane after a messier suggestion by me.
2007-06-05Move call of MarkBufferDirty() before XLogInsert() as required.Teodor Sigaev
Many thanks to Heikki Linnakangas <heikki@enterprisedb.com> for his sharp eyes.
2007-06-04Fix bundle bugs of GIN:Teodor Sigaev
- Fix possible deadlock between UPDATE and VACUUM queries. Bug never was observed in 8.2, but it still exist there. HEAD is more sensitive to bug after recent "ring" of buffer improvements. - Fix WAL creation: if parent page is stored as is after split then incomplete split isn't removed during replay. This happens rather rare, only on large tables with a lot of updates/inserts. - Fix WAL replay: there was wrong test of XLR_BKP_BLOCK_* for left page after deletion of page. That causes wrong rightlink field: it pointed to deleted page. - add checking of match of clearing incomplete split - cleanup incomplete split list after proceeding All of this chages doesn't change on-disk storage, so backpatch... But second point may be an issue for replaying logs from previous version.
2007-06-04On win32, retry reading when WSARecv returns WSAEWOULDBLOCK. There seemMagnus Hagander
to be cases when at least Windows 2000 can do this even though select just indicated that the socket is readable. Per report and analysis from Cyril VELTER.
2007-06-04On win32, don't use SO_REUSEADDR for TCP sockets.Magnus Hagander
Per failure on buildfarm member baiji and subsequent discussion.
2007-06-02Fix erroneous error reporting for overlength input in text_date(),Tom Lane
text_time(), and text_timetz(). 7.4-vintage bug found by Greg Stark.
2007-06-01Fix aboriginal bug in BufFileDumpBuffer that would cause it to write theTom Lane
wrong data when dumping a bufferload that crosses a component-file boundary. This probably has not been seen in the wild because (a) component files are normally 1GB apiece and (b) non-block-aligned buffer usage is relatively rare. But it's fairly easy to reproduce a problem if one reduces RELSEG_SIZE in a test build. Kudos to Kurt Harriman for spotting the bug.