Commit Graph

20123 Commits

Author SHA1 Message Date
Tom Lane
052e884e8b Add SPI_push/SPI_pop calls so that datatype input and output functions called
by plpgsql can themselves use SPI --- possibly indirectly, as in the case
of domain_in() invoking plpgsql functions in a domain check constraint.
Per bug #2945 from Sergiy Vyshnevetskiy.

Somewhat arbitrarily, I've chosen to back-patch this as far as 8.0.  Given
the lack of prior complaints, it doesn't seem critical for 7.x.
2007-01-30 18:02:40 +00:00
Tom Lane
f109cb1285 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:46 +00:00
Tom Lane
6b8a7cfadc 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:35 +00:00
Tom Lane
3e0b5417a5 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:26:02 +00:00
Tatsuo Ishii
8147c13f6f 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-13 03:17:34 +00:00
PostgreSQL Daemon
a7542c3bb1 tag it 2007-01-06 06:18:46 +00:00
Tom Lane
3d5f28671a Links to GUC variables from HISTORY don't work in back branches... 2007-01-06 06:01:48 +00:00
Bruce Momjian
a05e93ed52 Fix markup because older releases couldn't link to the reference section. 2007-01-06 04:17:33 +00:00
Tom Lane
ccd743ef5d Minor copy-editing for release note updates. 2007-01-05 22:35:04 +00:00
Bruce Momjian
e0f20bbe44 Stamp release 8.0.10. 2007-01-05 20:53:30 +00:00
Bruce Momjian
1f503f27d5 Create release notes for 8.0.10. 2007-01-05 20:03:19 +00:00
Tom Lane
85690a0e1a 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:49 +00:00
Tom Lane
cbca48aa24 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:10 +00:00
Teodor Sigaev
b328083249 Fix convertion for 'PFX flag N num' 2006-12-21 17:36:08 +00:00
Tom Lane
1eaf9ef62a 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:50:06 +00:00
Tom Lane
8462c4a5b4 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:23 +00:00
Tom Lane
894bfdcdb0 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:19:07 +00:00
Tom Lane
fc821135fb 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:07:01 +00:00
Tom Lane
db8a3fd680 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:13:04 +00:00
Tom Lane
b8222e5006 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:10 +00:00
Tom Lane
006284b2ef 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:37 +00:00
Michael Meskes
171f936b51 Applied patch by Peter Harris to free auto_mem struct in ECPGconnect. 2006-11-08 10:48:21 +00:00
Tom Lane
fc8c5fbf5d 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:47 +00:00
Tom Lane
b4f5429fa8 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:08 +00:00
Tom Lane
3aba3aa5b4 Back-patch second version of AIX getaddrinfo fix. 2006-10-20 01:10:35 +00:00
Tom Lane
375cb7cfb0 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:43 +00:00
Teodor Sigaev
10a6e431d3 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:41 +00:00
Tom Lane
9a0d9968b2 Stamp 8.0.9. 2006-10-12 19:41:43 +00:00
Tom Lane
db9ebafca1 Update release notes for SQL functions vs triggers fix. 2006-10-12 19:25:32 +00:00
Tom Lane
9a0271bd31 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:34 +00:00
Tom Lane
b6a71905d3 A bit of copy-editing on back-branch release notes. 2006-10-11 20:56:10 +00:00
Tom Lane
dc167085f3 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:19 +00:00
Tom Lane
8608aa9534 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:18 +00:00
Tom Lane
13abcaba80 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:28 +00:00
Bruce Momjian
bc0fa10440 Stamp releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5. 2006-10-09 23:38:46 +00:00
Bruce Momjian
b07bda6312 Update release notes for releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5. 2006-10-09 23:23:29 +00:00
Tom Lane
3d32b17798 Fix back-branch pg_regress scripts to try the "canonical" expected file if we
tried a variant file from resultmap and it didn't match.  This is already done
in HEAD's C-code version, and is needed because OpenBSD has recently migrated
to a more standard handling of float underflow --- see buildfarm results
from emu.
2006-10-09 01:45:49 +00:00
Tom Lane
5361743826 Fix ancient oversight in psql's \d pattern processing code: when seeing two
quote chars inside quote marks, should emit one quote *and stay in inquotes
mode*.  No doubt the lack of reports of this have something to do with the
poor documentation of the feature ...
2006-10-07 22:21:50 +00:00
Tom Lane
704f8ea11c Fix string_to_array() to correctly handle the case where there are
overlapping possible matches for the separator string, such as
string_to_array('123xx456xxx789', 'xx').
Also, revise the logic of replace(), split_part(), and string_to_array()
to avoid O(N^2) work from redundant searches and conversions to pg_wchar
format when there are N matches to the separator string.
Backpatched the full patch as far as 8.0.  7.4 also has the bug, but the
code has diverged a lot, so I just went for a quick-and-dirty fix of the
bug itself in that branch.
2006-10-07 00:12:05 +00:00
Tom Lane
d2cc024be1 Fix SysCacheGetAttr() to handle the case where the specified syscache has not
been initialized yet.  This can happen because there are code paths that call
SysCacheGetAttr() on a tuple originally fetched from a different syscache
(hopefully on the same catalog) than the one specified in the call.  It
doesn't seem useful or robust to try to prevent that from happening, so just
improve the function to cope instead.  Per bug#2678 from Jeff Trout.  The
specific example shown by Jeff is new in 8.1, but to be on the safe side
I'm backpatching 8.0 as well.  We could patch 7.x similarly but I think
that's probably overkill, given the lack of evidence of old bugs of this ilk.
2006-10-06 18:23:48 +00:00
Tom Lane
4d3760f674 date_trunc also accepts 'quarter'. Noted by Yoshihisa Nakano. 2006-10-01 18:54:48 +00:00
Tom Lane
220db233f8 Clean up rather sloppy fix in HEAD for the ancient bug that CREATE CONVERSION
didn't create a dependency from the new conversion to its schema.  Back-patch
to all supported releases.
2006-08-31 17:31:48 +00:00
Teodor Sigaev
b0e56b9c0d Fix mistyping 2006-08-29 15:49:00 +00:00
Andrew Dunstan
1aaecd41a6 Add installcheck-parallel target to top level makefiles. 2006-08-18 19:59:05 +00:00
Michael Meskes
2d280ef3fb Backported buffer overrun fix from HEAD 2006-08-18 16:33:50 +00:00
Michael Meskes
95a5a29845 Applied the connect patch from HEAD 2006-08-18 16:00:49 +00:00
Teodor Sigaev
09e33d1628 Fix bug introduced by last patch, thanks again to Mario Weilguni <mweilguni@sime.com> 2006-08-08 15:45:56 +00:00
Tom Lane
01c74da47e Back-port HEAD's configure fixes to select appropriate compiler switches
for Intel's icc and AIX's xlc.
2006-08-07 20:08:57 +00:00
Teodor Sigaev
9a7788fb4d fix bug about modifying value in shared buffer,
what was a reason to corrupt index.
Thank to Mario Weilguni <mweilguni@sime.com> to
discover a bug.
2006-08-07 17:40:53 +00:00
Alvaro Herrera
632db651cb Fix confusion between COPY FROM and COPY TO, per Gavin Sharry and Arul Shaji. 2006-07-31 01:09:48 +00:00