Commit Graph

21880 Commits

Author SHA1 Message Date
Tom Lane
722ad326f1 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:55 +00:00
Tom Lane
03d1281477 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:29 +00:00
Tom Lane
212df03ac9 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:56 +00:00
Neil Conway
bdc9d70edd 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:51 +00:00
Alvaro Herrera
d8b5a71c51 Fix autovacuum to avoid leaving non-permanent Xids in non-connectable
databases.

Apply to the 8.1 branch only, as the new 8.2 (and HEAD) coding does not have
this problem.
2007-01-14 20:18:30 +00:00
Tom Lane
0069d7c36a 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:16 +00:00
Tatsuo Ishii
e6be37ffe2 Back port 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:44:30 +00:00
Tom Lane
c3013376b2 Links to GUC variables from HISTORY don't work in back branches... 2007-01-06 06:01:37 +00:00
PostgreSQL Daemon
e677ff2876 tag 8.1.6 2007-01-06 05:29:03 +00:00
Bruce Momjian
96959c18c6 Fix markup because older releases couldn't link to the reference section. 2007-01-06 04:17:59 +00:00
Tom Lane
17406c92ac Minor copy-editing for release note updates. 2007-01-05 22:34:54 +00:00
Bruce Momjian
9b9758bb77 Stamp release 8.1.6. 2007-01-05 20:53:49 +00:00
Bruce Momjian
f921940be5 Create release notes for 8.1.6. 2007-01-05 20:03:46 +00:00
Tom Lane
15888bf0c0 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:42 +00:00
Tom Lane
34aabc2071 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:32:03 +00:00
Tom Lane
f1d8828e3c 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:27:04 +00:00
Teodor Sigaev
3dd05aba09 Fix convertion for 'PFX flag N num' 2006-12-21 17:35:55 +00:00
Tom Lane
2244ccd408 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...
2006-12-01 20:49:59 +00:00
Tom Lane
95f6a47f1a Update timezone data to tzdata2006p zic distribution. It seems Western
Australia decided to institute DST with one month's notice ... way to go,
politicians.
2006-11-28 19:37:13 +00:00
Tom Lane
0b11a15259 Mark to_number() and the numeric-type variants of to_char() as stable, not
immutable, because their results depend on lc_numeric; this is a longstanding
oversight.  We cannot force initdb for this in the back branches, but we can
at least provide correct catalog entries for future installations.
2006-11-28 19:18:56 +00:00
Tom Lane
583159ff69 Back-patch HEAD's fixes to recognize __ppc64__ as equivalent to __powerpc64__.
Per confirmation from Brian Wipf that this is correct and necessary for
Darwin 64-bit.
2006-11-28 05:54:32 +00:00
Tom Lane
6db9d26727 Add $(CFLAGS) to the simplified build rule for .so libraries on Darwin.
Arguably we should do this on *all* platforms, but for the moment I'll be
conservative and just do it where it's demonstrably needed.  Per report
from Brian Wipf.
2006-11-28 05:47:16 +00:00
Tom Lane
2f523a6f53 Fix psql's \copy command to ensure that it cycles libpq back to the idle state
(in particular, causing the ReadyForQuery message to be eaten) before
returning from do_copy.  The only known consequence of failing to do so is
that get_prompt might show a wrong result for the %x transaction status
escape, as reported by Bernd Helmle; but it's possible there are other issues.

Back-patch as far as 7.4, the oldest version supporting %x.
2006-11-24 23:06:56 +00:00
Bruce Momjian
35f9bf3725 Add release entry for 8.1.5 that was missing:
<listitem><para>Fix rare bug in continuous archiving (Tom)</para></listitem>
2006-11-23 03:31:04 +00:00
Tom Lane
c4950aa1ee Fix 1-byte buffer overrun when OID exceeds 1 billion. This probably can't
cause any serious harm in normal cases, but if you have gcc buffer overrun
checking turned on, that will notice.  Found by Jack Orenstein.  Problem
was already fixed in CVS HEAD.
2006-11-22 21:12:57 +00:00
Tom Lane
504d87c7cd When truncating a relation in-place (eg during VACUUM), do not try to unlink
any no-longer-needed segments; just truncate them to zero bytes and leave
the files in place for possible future re-use.  This avoids problems when
the segments are re-used due to relation growth shortly after truncation.
Before, the bgwriter, and possibly other backends, could still be holding
open file references to the old segment files, and would write dirty blocks
into those files where they'd disappear from the view of other processes.

Back-patch as far as 8.0.  I believe the 7.x branches are not vulnerable,
because they had no bgwriter, and "blind" writes by other backends would
always be done via freshly-opened file references.
2006-11-20 01:08:02 +00:00
Tom Lane
dfb25d2863 Repair problems with hash indexes that span multiple segments: the hash code's
preference for filling pages out-of-order tends to confuse the sanity checks
in md.c, as per report from Balazs Nagy in bug #2737.  The fix is to ensure
that the smgr-level code always has the same idea of the logical EOF as the
hash index code does, by using ReadBuffer(P_NEW) where we are adding a single
page to the end of the index, and using smgrextend() to reserve a large batch
of pages when creating a new splitpoint.  The patch is a bit ugly because it
avoids making any changes in md.c, which seems the most prudent approach for a
backpatchable beta-period fix.  After 8.3 development opens, I'll take a look
at a cleaner but more invasive patch, in particular getting rid of the now
unnecessary hack to allow reading beyond EOF in mdread().

Backpatch as far as 7.4.  The bug likely exists in 7.3 as well, but because
of the magnitude of the 7.3-to-7.4 changes in hash, the later-version patch
doesn't even begin to apply.  Given the other known bugs in the 7.3-era hash
code, it does not seem worth trying to develop a separate patch for 7.3.
2006-11-19 21:33:29 +00:00
Tom Lane
91eb4895bb Repair two related errors in heap_lock_tuple: it was failing to recognize
cases where we already hold the desired lock "indirectly", either via
membership in a MultiXact or because the lock was originally taken by a
different subtransaction of the current transaction.  These cases must be
accounted for to avoid needless deadlocks and/or inappropriate replacement of
an exclusive lock with a shared lock.  Per report from Clarence Gardner and
subsequent investigation.
2006-11-17 18:00:25 +00:00
Michael Meskes
a2281c8e6f Applied patch by Peter Harris to free auto_mem struct in ECPGconnect. 2006-11-08 10:48:27 +00:00
Tom Lane
b3234f2912 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:38 +00:00
Tom Lane
befd4e4e48 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:38 +00:00
Tom Lane
23092b9928 Correct documentation error: in 8.1 and 8.2, %p in archive and restore
command strings inserts relative not absolute path of file to process.
This is a side-effect of 2005-07-04 change that makes the server use
relative paths in general.  Noted by Bernd Helmle.
2006-11-04 18:20:40 +00:00
Tom Lane
6f48f84874 Fix "failed to re-find parent key" btree VACUUM failure by tweaking
_bt_pagedel to recover from the failure: just search the whole parent level
if searching to the right fails.  This does nothing for the underlying problem
that index keys became out-of-order in the grandparent level.  However, we
believe that there is no other consequence worse than slightly inefficient
searching, so this narrow patch seems like the safest solution for the back
branches.
2006-11-01 19:50:03 +00:00
Tom Lane
ecaa7ebed8 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:31 +00:00
Tom Lane
8a6ed093b4 Back-patch second version of AIX getaddrinfo fix. 2006-10-20 01:10:28 +00:00
Tom Lane
62fc3b9929 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:37 +00:00
Bruce Momjian
09b98773ab Update Japanese FAQ.
Jun Kuwamura
2006-10-13 17:30:13 +00:00
Tom Lane
91ddf5b548 Fix typo in version number. 2006-10-13 15:25:09 +00:00
Teodor Sigaev
9f1b531420 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 14:00:17 +00:00
Tom Lane
87d57b6c93 Stamp 8.1.5. 2006-10-12 19:41:27 +00:00
Tom Lane
424157a803 Sync 8.1 pg_config.h.in with expected autoheader output (looks like
someone did this manually last time ...)
2006-10-12 19:29:30 +00:00
Tom Lane
9d457ea802 Update release notes for SQL functions vs triggers fix. 2006-10-12 19:25:22 +00:00
Tom Lane
fb27f43123 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:28 +00:00
Tom Lane
23c64e18ec A bit of copy-editing on back-branch release notes. 2006-10-11 20:56:01 +00:00
Tom Lane
c2caa7b736 Repair incorrect check for coercion of unknown literal to ANYARRAY, a bug
I introduced in 7.4.1 :-(.  It's correct to allow unknown to be coerced to
ANY or ANYELEMENT, since it's a real-enough data type, but it most certainly
isn't an array datatype.  This can cause a backend crash but AFAICT is not
exploitable as a security hole.  Per report from Michael Fuhr.

Note: as fixed in HEAD, this changes a constant in the pg_stats view,
resulting in a change in the expected regression outputs.  The back-branch
patches have been hacked to avoid that, so that pre-existing installations
won't start failing their regression tests.
2006-10-11 20:21:11 +00:00
Tom Lane
97fc0f6e83 CREATE TABLE ... LIKE ... should mark the columns it creates with
attislocal = true, since they are not really inherited but merely copied
from the original table.  I'm not sure if there are any cases where it makes
a real difference given the existing uses of the flag, but wrong is wrong.
This was fixed in passing in HEAD by the LIKE INCLUDING CONSTRAINTS patch,
but never back-patched.
2006-10-11 20:03:11 +00:00
Bruce Momjian
34cd09fdd0 Restore HPUX FAQ entry that talked about working around regression
script problems, because in 8.1.X, the regression test is still a
script.  Patch to 8.1.X only.
2006-10-10 20:11:44 +00:00
Tom Lane
9c2b6ec695 Fix psql \d commands to behave properly when a pattern using regex | is given.
Formerly they'd emit '^foo|bar$' which is wrong because the anchors are
parsed as part of the alternatives; must emit '^(foo|bar)$' to get expected
behavior.  Same as bug found previously in similar_escape().  Already fixed
in HEAD, this is just back-porting the part of that patch that was a bug fix.
2006-10-10 16:15:22 +00:00
Bruce Momjian
61c91fd2d2 Backpatch FAQs to 8.1.X. 2006-10-10 00:29:15 +00:00
Bruce Momjian
7cec8b4e4a Stamp releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5. 2006-10-09 23:39:03 +00:00