Commit Graph

16470 Commits

Author SHA1 Message Date
Tom Lane 808b3190d1 Modify aset.c to track the next intended block allocation size explicitly.
The former coding relied on the actual allocated size of the last block,
which made it behave strangely if the first allocation in a context was
larger than ALLOC_CHUNK_LIMIT: subsequent allocations would be referenced
to that and not to the intended series of block sizes.  Noted while
studying a memory wastage gripe from Tatsuo.
2006-11-08 19:27:24 +00:00
Tom Lane fc5eb3f69a Tweak accumArrayResult() to double the size of its working arrays when
more space is needed, instead of incrementing by a fixed amount; the old
method wastes lots of space and time when the ultimate size is large.
Per gripe from Tatsuo.
2006-11-08 19:24:38 +00:00
Tom Lane a5cf12e2ef Fix performance issues in replace_text(), replace_text_regexp(), and
text_to_array(): they all had O(N^2) behavior on long input strings in
multibyte encodings, because of repeated rescanning of the input text to
identify substrings whose positions/lengths were computed in characters
instead of bytes.  Fix by tracking the current source position as a char
pointer as well as a character-count.  Also avoid some unnecessary palloc
operations.  text_to_array() also leaked memory intracall due to failure
to pfree temporary strings.  Per gripe from Tatsuo Ishii.
2006-11-08 19:22:25 +00:00
Michael Meskes 0c96e42797 Applied patch by Peter Harris to free auto_mem structure on connect 2006-11-08 10:46:47 +00:00
Neil Conway 415b925345 Fix a memory leak in psql: we'd leak a few PGresult handles if
a connectivity error occurred while executing one of the queries
for "\d <table>". Not serious, but still worth fixing. Patch from
Brendan Jurd.
2006-11-08 01:22:55 +00:00
Neil Conway 8964b41c7b Remove a 15-year old comment questioning behavior that is now well-
established: referencing an undefined parameter should result in an
error, not NULL.
2006-11-08 00:45:30 +00:00
PostgreSQL Daemon 9b3aee524f Tag as Beta3 ... two outstanding *known* bugs before RC1 ... 2006-11-07 17:59:05 +00:00
Tom Lane f0395d50e9 Repair bug #2694 concerning an ARRAY[] construct whose inputs are empty
sub-arrays.  Per discussion, if all inputs are empty arrays then result
must be an empty array too, whereas a mix of empty and nonempty arrays
should (and already did) draw an error.  In the back branches, the
construct was strict: any NULL input immediately yielded a NULL output;
so I left that behavior alone.  HEAD was simply ignoring NULL sub-arrays,
which doesn't seem very sensible.  For lack of a better idea it now
treats NULL sub-arrays the same as empty ones.
2006-11-06 18:21:31 +00:00
Tom Lane 36e012e727 Remove temporary Windows-specific debugging code; it seems the problem
with fopen() not using FILE_SHARE_DELETE was indeed the bug we were after,
given lack of recent reports.
2006-11-06 17:10:22 +00:00
Tom Lane 02f37bd8c4 Revert to the pre-8.2 method of probing for libm, that is, always
include it if it links properly.  It seems too risky to assume that
standard functions like pow() are not special-cased by the compiler.
Per report from Andreas Lange that build fails on Solaris cc compiler
with -fast.  Even though we don't consider that a supported option,
I'm worried that similar issues will arise with other compilers.
2006-11-06 03:44:38 +00:00
Tom Lane 74686b6de7 Get rid of some unnecessary dependencies on DataDir: wherever possible,
the backend should rely on its working-directory setting instead.
Also do some message-style police work in contrib/adminpack.
2006-11-06 03:06:41 +00:00
Neil Conway 62fe410ec6 Minor fix for LDAP authentication: if an error occurs, we need to
manually release the LDAP handle via ldap_unbind(). This isn't a
significant problem in practice because an error eventually results
in exiting the process, but we can cleanup correctly without too
much pain.

In passing, fix an error in snprintf() usage: the "size" parameter
to snprintf() is the size of the destination buffer, including space
for the NUL terminator. Also, depending on the value of NAMEDATALEN,
the old coding could have allowed for a buffer overflow.
2006-11-06 01:27:52 +00:00
Tom Lane 76d5667ba8 Fix recently-identified PITR recovery hazard: the base backup could contain
stale relcache init files (pg_internal.init), and there is no mechanism for
updating them during WAL replay.  Easiest solution is just to delete the init
files at conclusion of startup, and let the first backend started in each
database take care of rebuilding the init file.  Simon Riggs and Tom Lane.

Back-patched to 8.1.  Arguably this should be fixed in 8.0 too, but it would
require significantly more code since 8.0 has no handy startup-time scan of
pg_database to piggyback on.  Manual solution of the problem is possible
in 8.0 (just delete the pg_internal.init files before starting WAL replay),
so that may be a sufficient answer.
2006-11-05 23:40:31 +00:00
Tom Lane 48188e1621 Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios.  We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases.  Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId.  Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done.  Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database.  initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs.  Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-11-05 22:42:10 +00:00
Tom Lane 70ce5c9082 Fix "failed to re-find parent key" btree VACUUM failure by revising page
deletion code to avoid the case where an upper-level btree page remains "half
dead" for a significant period of time, and to block insertions into a key
range that is in process of being re-assigned to the right sibling of the
deleted page's parent.  This prevents the scenario reported by Ed L. wherein
index keys could become out-of-order in the grandparent index level.

Since this is a moderately invasive fix, I'm applying it only to HEAD.
The bug exists back to 7.4, but the back branches will get a different patch.
2006-11-01 19:43:17 +00:00
Tom Lane 19d0c46def pg_restore failed on tar-format archives if they contained large objects
(blobs) with comments, per bug #2727 from Konstantin Pelepelin.
Mea culpa for not having tested this case.
Back-patch to 8.1; prior branches don't dump blob comments at all.
2006-11-01 15:59:26 +00:00
Tom Lane c1fdbba49f Update zic database to tzdata2006n. 2006-11-01 05:20:38 +00:00
Tom Lane 76d5f6f035 expression_tree_walker failed to let walker function see the immediate child
node of a SubLink or SubPlan testexpr field.  Bug resulted from replacing
the old lefthand/exprs list fields with a simple expression field, and not
remembering that expression_tree_walker is coded to save a few cycles by
recursing directly to self on list fields (on the assumption the walker
isn't interested in List nodes per se).  On non-list fields it must of
course call the walker.  Possibly that hack isn't worth the risk of more
such bugs, but I'll leave it be for now.  Per bug report from James Robinson.
2006-10-25 22:11:32 +00:00
Tom Lane 4df8de7a68 Fix check for whether a clauseless join has to be forced in the presence of
outer joins.  Originally it was only looking for overlap of the righthand
side of a left join, but we have to do it on the lefthand side too.
Per example from Jean-Pierre Pelletier.
2006-10-24 17:50:22 +00:00
Tom Lane d8221dfa6d Tweak zic.c to compile cleanly on MSVC: use CopyFile instead of
CopyFileEx.  This avoids a warning about the function not being
present on older Windows versions.  Magnus Hagander
2006-10-24 15:11:03 +00:00
Tom Lane 66f5264a2e Stamp 8.2beta2. 2006-10-23 22:50:20 +00:00
Michael Meskes a09f9ff649 Small parser sync 2006-10-23 08:00:48 +00:00
Tom Lane 954c1813ac Remove an unnecessary HOLD_INTERRUPTS/RESUME_INTERRUPTS pair.
This was required back when RESUME_INTERRUPTS could actually
execute ProcessInterrupts, but that hasn't been true since 2001...
2006-10-22 20:34:54 +00:00
Tom Lane c2c0b14086 Various MSVC build fixes from Magnus; also remove stray Windows
newlines.
2006-10-22 17:17:09 +00:00
Peter Eisentraut 9c2c41646a Translations update 2006-10-21 21:03:04 +00:00
Tom Lane 33af087695 Try to fix the AIX getaddrinfo mess in a way that works on all versions.
Going to wait for buildfarm results before backpatching, this time.
2006-10-19 23:17:39 +00:00
Tom Lane 1b84441a49 Marginal improvement in logging: include the function name when logging
a fastpath function call.
2006-10-19 22:44:11 +00:00
Tom Lane 4887f5f979 Rename our substitute qsort to pg_qsort at the link-symbol level (but
provide a macro so code can still just say qsort).  Avoids linker warnings
on pickier platforms such as Darwin, and outright failure on MSVC.
2006-10-19 20:56:22 +00:00
Tom Lane 443abd83e5 Add externs for optarg/optind where apparently needed. Per Magnus. 2006-10-19 20:38:48 +00:00
Tom Lane f6e00ae128 Further MSVC portability fixes from Magnus. 2006-10-19 20:03:08 +00:00
Tom Lane 2315df21f8 Fix a couple of places that were assuming debug_query_string couldn't
be NULL ... seems an unsafe assumption.
2006-10-19 19:53:03 +00:00
Tom Lane 681892208f Make sure that debug_query_string contains the original query text,
if available (which it usually should be), during processing of Bind
and Execute protocol messages.  This improves usefulness of
log_min_error_statement logging for extended query protocol.
2006-10-19 19:52:22 +00:00
Tom Lane def651f48f Clean up local redeclarations of variables with DLLIMPORT, per report
from Magnus that MSVC complains about this.
2006-10-19 18:32:48 +00:00
Tom Lane dbb397f30f Work around reported problem that AIX's getaddrinfo() doesn't seem to zero
sin_port in the returned IP address struct when servname is NULL.  This has
been observed to cause failure to bind the stats collection socket, and
could perhaps cause other issues too.  Per reports from Brad Nicholson
and Chris Browne.
2006-10-19 17:26:32 +00:00
Tom Lane 1e758d5263 Add some code to CREATE DATABASE to check for pre-existing subdirectories
that conflict with the OID that we want to use for the new database.
This avoids the risk of trying to remove files that maybe we shouldn't
remove.  Per gripe from Jon Lapham and subsequent discussion of 27-Sep.
2006-10-18 22:44:12 +00:00
Tom Lane 877f08da14 Fix up timetz input so that a date is required only when the specified
timezone actually has a daylight-savings rule.  This avoids breaking
cases that used to work because they went through the DecodePosixTimezone
code path.  Per contrib regression failures (mea culpa for not running
those yesterday...).  Also document the already-applied change to allow
GMT offsets up to 14 hours.
2006-10-18 16:43:14 +00:00
Tom Lane 022fd99668 Fix up some problems in handling of zic-style time zone names in datetime
input routines.  Remove the former "DecodePosixTimezone" function in favor of
letting the zic code handle POSIX-style zone specs (see tzparse()).  In
particular this means that "PST+3" now means the same as "-03", whereas it
used to mean "-11" --- the zone abbreviation is effectively just a noise word
in this syntax.  Make sure that all named and POSIX-style zone names will be
parsed as a single token.  Fix long-standing bogosities in printing and input
of fractional-hour timezone offsets (since the tzparse() code will accept
these, we'd better make 'em work).  Also correct an error in the original
coding of the zic-zone-name patch: in "timestamp without time zone" input,
zone names are supposed to be allowed but ignored, but the coding was such
that the zone changed the interpretation anyway.
2006-10-17 21:03:21 +00:00
Tom Lane 14914e0d33 Fix unexpected side-effect of changes for case insensitivity of timezone names. 2006-10-17 02:21:46 +00:00
Peter Eisentraut 3e584e071b Remove use of whrandom module, which was removed in Python 2.5. 2006-10-16 21:13:57 +00:00
Tom Lane 0b35b01e7a Arrange for timezone names to be recognized case-insensitively; for
example SET TIME ZONE 'america/new_york' works now.  This seems a good
idea on general user-friendliness grounds, and is part of the solution
to the timestamp-input parsing problems I noted recently.
2006-10-16 19:58:27 +00:00
Bruce Momjian 389fad1e6b Remove use of '<' and '>' in SGML, use '&' escapes.
Update find_gt_lt to allow grep parameters to be passed into it.
2006-10-16 17:28:03 +00:00
Tom Lane e0dece127d Redesign the patch for allocation of shmem space and LWLocks for add-on
modules; the first try was not usable in EXEC_BACKEND builds (e.g.,
Windows).  Instead, just provide some entry points to increase the
allocation requests during postmaster start, and provide a dedicated
LWLock that can be used to synchronize allocation operations performed
by backends.  Per discussion with Marc Munro.
2006-10-15 22:04:08 +00:00
Tom Lane a3dff39c53 Adjust plperl to ensure that all strings and hash keys passed to Perl
are marked as UTF8 when the database encoding is UTF8.  This should
avoid inconsistencies like that exhibited in bug #2683 from Vitali Stupin.
2006-10-15 18:56:39 +00:00
Tom Lane 1314983fd3 Code review for --no-data-for-failed-tables patch. Instead of trashing
one of the program's core data structures, make use of the existing
ability to selectively exclude TOC items by ID.  Slightly more code but
much less likely to create future maintenance problems.
2006-10-14 23:07:22 +00:00
Tom Lane f58eac82ee Code and docs review for ALTER TABLE INHERIT/NO INHERIT patch. 2006-10-13 21:43:19 +00:00
Bruce Momjian 5777dca4f8 Fix test_fsync compile on MinGW(win32)
Hiroshi Saito
2006-10-13 14:19:29 +00:00
Teodor Sigaev 47df6e7e2d Fix infinite sleep and failes of send in Win32.
1) pgwin32_waitforsinglesocket(): WaitForMultipleObjectsEx now called with
finite timeout (100ms) in case of FP_WRITE and UDP socket. If timeout occurs
then pgwin32_waitforsinglesocket() tries to write empty packet goes to
WaitForMultipleObjectsEx again.

2) pgwin32_send(): add loop around WSASend and pgwin32_waitforsinglesocket().
The reason is: for overlapped socket, 'ok' result from
pgwin32_waitforsinglesocket() isn't guarantee that socket is still free,
it can become busy again and following WSASend call will fail with
WSAEWOULDBLOCK error.

See http://archives.postgresql.org/pgsql-hackers/2006-10/msg00561.php
2006-10-13 13:59:47 +00:00
Tom Lane d2e17e1ddc Fix mishandling of after-trigger state when a SQL function returns multiple
rows --- if the surrounding query queued any trigger events between the rows,
the events would be fired at the wrong time, leading to bizarre behavior.
Per report from Merlin Moncure.

This is a simple patch that should solve the problem fully in the back
branches, but in HEAD we also need to consider the possibility of queries
with RETURNING clauses.  Will look into a fix for that separately.
2006-10-12 17:02:24 +00:00
Tom Lane b38900c767 Use Min() instead of min() in qsort, for consistency and to avoid
redefined-macro warnings on some platforms.  Per gripe from Hiroshi Saito.
2006-10-12 15:04:55 +00:00
Tom Lane a50606de91 Remove somebody's ill-considered free() call, per report from Chander Ganesan.
No, I do not care whether Coverity considers this a memory leak.
It's entirely not worth the code space to do it correctly.
2006-10-12 05:14:49 +00:00