]> git.ipfire.org Git - thirdparty/postgresql.git/log
thirdparty/postgresql.git
17 years agoOnly use the pipe chunking protocol if we know the syslogger should
Andrew Dunstan [Thu, 19 Jul 2007 19:15:25 +0000 (19:15 +0000)] 
Only use the pipe chunking protocol if we know the syslogger should
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.

18 years agoFix incorrect optimization of foreign-key checks. When an UPDATE on the
Tom Lane [Tue, 17 Jul 2007 17:45:57 +0000 (17:45 +0000)] 
Fix incorrect optimization of foreign-key checks.  When an UPDATE on the
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.

18 years agoFix outfuncs.c to dump A_Const nodes representing NULLs correctly. This has
Tom Lane [Tue, 17 Jul 2007 01:22:11 +0000 (01:22 +0000)] 
Fix outfuncs.c to dump A_Const nodes representing NULLs correctly.  This has
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.

18 years agoRestrict non-superusers to password authenticated connections
Joe Conway [Mon, 9 Jul 2007 01:32:58 +0000 (01:32 +0000)] 
Restrict non-superusers to password authenticated connections
to prevent possible escalation of privilege. Provide new SECURITY
DEFINER functions with old behavior, but initially REVOKE ALL
from public for these functions. Per list discussion and design
proposed by Tom Lane.

18 years agoFix failure to restart Postgres when Linux kernel returns EIDRM for shmctl().
Tom Lane [Mon, 2 Jul 2007 20:12:11 +0000 (20:12 +0000)] 
Fix failure to restart Postgres when Linux kernel returns EIDRM for shmctl().

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.

18 years agoFix a passel of ancient bugs in to_char(), including two distinct buffer
Tom Lane [Fri, 29 Jun 2007 01:52:04 +0000 (01:52 +0000)] 
Fix a passel of ancient bugs in to_char(), including two distinct buffer
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.

18 years agoFix incorrect tests for undef Perl values in some places in plperl.c.
Tom Lane [Thu, 28 Jun 2007 17:50:24 +0000 (17:50 +0000)] 
Fix incorrect tests for undef Perl values in some places in plperl.c.
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.

18 years agotransformColumnDefinition failed to complain about
Tom Lane [Wed, 20 Jun 2007 18:21:25 +0000 (18:21 +0000)] 
transformColumnDefinition failed to complain about
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.

18 years agoCREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULT
Tom Lane [Wed, 20 Jun 2007 18:16:10 +0000 (18:16 +0000)] 
CREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULT
NULL and DefineDomain didn't.  Bug goes all the way back to original coding
of domains.  Per bug #3396 from Sergey Burladyan.

18 years agoImplement a chunking protocol for writes to the syslogger pipe, with messages
Andrew Dunstan [Thu, 14 Jun 2007 01:50:35 +0000 (01:50 +0000)] 
Implement a chunking protocol for writes to the syslogger pipe, with messages
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

18 years agoAllow numeric_fac() to be interrupted, since it can take quite a while for
Tom Lane [Sat, 9 Jun 2007 15:52:54 +0000 (15:52 +0000)] 
Allow numeric_fac() to be interrupted, since it can take quite a while for
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.

18 years agoFix array_dims() example to be consistent with the data previously shown.
Tom Lane [Thu, 7 Jun 2007 14:50:18 +0000 (14:50 +0000)] 
Fix array_dims() example to be consistent with the data previously shown.
Christian Rossow

18 years agoOn win32, don't use SO_REUSEADDR for TCP sockets.
Magnus Hagander [Mon, 4 Jun 2007 11:59:27 +0000 (11:59 +0000)] 
On win32, don't use SO_REUSEADDR for TCP sockets.

Per failure on buildfarm member baiji and subsequent discussion.

18 years agoFix erroneous error reporting for overlength input in text_date(),
Tom Lane [Sat, 2 Jun 2007 16:41:31 +0000 (16:41 +0000)] 
Fix erroneous error reporting for overlength input in text_date(),
text_time(), and text_timetz().  7.4-vintage bug found by Greg Stark.

18 years agoFix aboriginal bug in BufFileDumpBuffer that would cause it to write the
Tom Lane [Fri, 1 Jun 2007 23:43:28 +0000 (23:43 +0000)] 
Fix aboriginal bug in BufFileDumpBuffer that would cause it to write the
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.

18 years agoFix overly-strict sanity check in BeginInternalSubTransaction that made it
Tom Lane [Wed, 30 May 2007 21:02:02 +0000 (21:02 +0000)] 
Fix overly-strict sanity check in BeginInternalSubTransaction that made it
fail when used in a deferred trigger.  Bug goes back to 8.0; no doubt the
reason it hadn't been noticed is that we've been discouraging use of
user-defined constraint triggers.  Per report from Frank van Vugt.

18 years agoFix spurious German index entry
Peter Eisentraut [Mon, 21 May 2007 15:06:44 +0000 (15:06 +0000)] 
Fix spurious German index entry

18 years agoRemove redundant logging of send failures when SSL is in use. While pqcomm.c
Tom Lane [Fri, 18 May 2007 01:20:40 +0000 (01:20 +0000)] 
Remove redundant logging of send failures when SSL is in use.  While pqcomm.c
had been taught not to do that ages ago, the SSL code was helpfully bleating
anyway.  Resolves some recent reports such as bug #3266; however the
underlying cause of the related bug #2829 is still unclear.

18 years agoDocument that CLUSTER breaks MVCC visibility rules.
Magnus Hagander [Sun, 13 May 2007 16:04:28 +0000 (16:04 +0000)] 
Document that CLUSTER breaks MVCC visibility rules.
(Not needed in cvs head, because CLUSTER itself is fixed there)

Heikki Linnakangas

18 years agoFix a thinko in my patch of a couple months ago for bug #3116: it did the
Tom Lane [Tue, 1 May 2007 18:54:17 +0000 (18:54 +0000)] 
Fix a thinko in my patch of a couple months ago for bug #3116: it did the
wrong thing when inlining polymorphic SQL functions, because it was using the
function's declared return type where it should have used the actual result
type of the current call.  In 8.1 and 8.2 this causes obvious failures even if
you don't have assertions turned on; in 8.0 and 7.4 it would only be a problem
if the inlined expression were used as an input to a function that did
run-time type determination on its inputs.  Add a regression test, since this
is evidently an under-tested area.

18 years agoFix dynahash.c to suppress hash bucket splits while a hash_seq_search() scan
Tom Lane [Thu, 26 Apr 2007 23:25:30 +0000 (23:25 +0000)] 
Fix dynahash.c to suppress hash bucket splits while a hash_seq_search() scan
is in progress on the same hashtable.  This seems the least invasive way to
fix the recently-recognized problem that a split could cause the scan to
visit entries twice or (with much lower probability) miss them entirely.
The only field-reported problem caused by this is the "failed to re-find
shared lock object" PANIC in COMMIT PREPARED reported by Michel Dorochevsky,
which was caused by multiply visited entries.  However, it seems certain
that mdsync() is vulnerable to missing required fsync's due to missed
entries, and I am fearful that RelationCacheInitializePhase2() might be at
risk as well.  Because of that and the generalized hazard presented by this
bug, back-patch all the supported branches.

Along the way, fix pg_prepared_statement() and pg_cursor() to not assume
that the hashtables they are examining will stay static between calls.
This is risky regardless of the newly noted dynahash problem, because
hash_seq_search() has never promised to cope with deletion of table entries
other than the just-returned one.  There may be no bug here because the only
supported way to call these functions is via ExecMakeTableFunctionResult()
which will cycle them to completion before doing anything very interesting,
but it seems best to get rid of the assumption.  This affects 8.2 and HEAD
only, since those functions weren't there earlier.

18 years agoFix newly-introduced documentation typo.
Neil Conway [Mon, 23 Apr 2007 16:53:09 +0000 (16:53 +0000)] 
Fix newly-introduced documentation typo.

18 years agoUpdate configure for release REL8_0_13
PostgreSQL Daemon [Fri, 20 Apr 2007 03:44:17 +0000 (03:44 +0000)] 
Update configure for release

Security: hold for release

18 years agoFix markup.
Tom Lane [Fri, 20 Apr 2007 03:27:54 +0000 (03:27 +0000)] 
Fix markup.

Security: CVE-2007-2138

18 years agoSupport explicit placement of the temporary-table schema within search_path.
Tom Lane [Fri, 20 Apr 2007 02:38:33 +0000 (02:38 +0000)] 
Support explicit placement of the temporary-table schema within search_path.
This is needed to allow a security-definer function to set a truly secure
value of search_path.  Without it, a malicious user can use temporary objects
to execute code with the privileges of the security-definer function.  Even
pushing the temp schema to the back of the search path is not quite good
enough, because a function or operator at the back of the path might still
capture control from one nearer the front due to having a more exact datatype
match.  Hence, disable searching the temp schema altogether for functions and
operators.

Security: CVE-2007-2138

18 years agoSync timezone data with 2007e zic release.
Tom Lane [Thu, 19 Apr 2007 22:44:51 +0000 (22:44 +0000)] 
Sync timezone data with 2007e zic release.

18 years agoRepair PANIC condition in hash indexes when a previous index extension attempt
Tom Lane [Thu, 19 Apr 2007 20:24:28 +0000 (20:24 +0000)] 
Repair PANIC condition in hash indexes when a previous index extension attempt
failed (due to lock conflicts or out-of-space).  We might have already
extended the index's filesystem EOF before failing, causing the EOF to be
beyond what the metapage says is the last used page.  Hence the invariant
maintained by the code needs to be "EOF is at or beyond last used page",
not "EOF is exactly the last used page".  Problem was created by my patch
of 2006-11-19 that attempted to repair bug #2737.  Since that was
back-patched to 7.4, this needs to be as well.  Per report and test case
from Vlastimil Krejcir.

18 years agoRelease wording updates for releases 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.
Bruce Momjian [Thu, 19 Apr 2007 13:02:15 +0000 (13:02 +0000)] 
Release wording updates for releases 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.

18 years agoUpdate FAQ to mention most recent release for releases
Bruce Momjian [Thu, 19 Apr 2007 04:04:41 +0000 (04:04 +0000)] 
Update FAQ to mention most recent release for releases
8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.

18 years agoStamp releases 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.
Bruce Momjian [Thu, 19 Apr 2007 03:06:46 +0000 (03:06 +0000)] 
Stamp releases 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.

18 years agoRelease note updates for 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.
Bruce Momjian [Thu, 19 Apr 2007 02:47:01 +0000 (02:47 +0000)] 
Release note updates for 8.2.4, 8.1.9, 8.0.13, 7.4.17, 7.3.19.

18 years agoTranslation updates
Peter Eisentraut [Wed, 18 Apr 2007 20:57:58 +0000 (20:57 +0000)] 
Translation updates

18 years agoDon't write timing output in quiet mode.
Magnus Hagander [Mon, 16 Apr 2007 20:15:53 +0000 (20:15 +0000)] 
Don't write timing output in quiet mode.

Merlin Moncure

18 years agoFix check_sql_fn_retval to allow the case where a SQL function declared to
Tom Lane [Mon, 2 Apr 2007 18:49:49 +0000 (18:49 +0000)] 
Fix check_sql_fn_retval to allow the case where a SQL function declared to
return void ends with a SELECT, if that SELECT has a single result that is
also of type void.  Without this, it's hard to write a void function that
calls another void function.  Per gripe from Peter.

Back-patch as far as 8.0.

18 years agoFix caching of unsuccessful initialization of parser or configuration.
Teodor Sigaev [Mon, 2 Apr 2007 11:43:11 +0000 (11:43 +0000)] 
Fix caching of unsuccessful initialization of parser or configuration.
Per report from Listmail <lists@peufeu.com>

18 years agoFix pg_wchar_table's maxmblen field of EUC_CN, EUC_TW, MULE_INTERNAL
Tatsuo Ishii [Mon, 26 Mar 2007 11:46:25 +0000 (11:46 +0000)] 
Fix pg_wchar_table's maxmblen field of EUC_CN, EUC_TW, MULE_INTERNAL
and GB18030. patches from ITAGAKI Takahiro.

18 years agoSPI_cursor_open failed to enforce that only read-only queries could be
Tom Lane [Sat, 17 Mar 2007 03:16:03 +0000 (03:16 +0000)] 
SPI_cursor_open failed to enforce that only read-only queries could be
executed in read_only mode.  This could lead to various relatively-subtle
failures, such as an allegedly stable function returning non-stable results.
Bug goes all the way back to the introduction of read-only mode in 8.0.
Per report from Gaetano Mendola.

18 years agoFix a longstanding bug in VACUUM FULL's handling of update chains. The code
Tom Lane [Wed, 14 Mar 2007 18:49:18 +0000 (18:49 +0000)] 
Fix a longstanding bug in VACUUM FULL's handling of update chains.  The code
did not expect that a DEAD tuple could follow a RECENTLY_DEAD tuple in an
update chain, but because the OldestXmin rule for determining deadness is a
simplification of reality, it is possible for this situation to occur
(implying that the RECENTLY_DEAD tuple is in fact dead to all observers,
but this patch does not attempt to exploit that).  The code would follow a
chain forward all the way, but then stop before a DEAD tuple when backing
up, meaning that not all of the chain got moved.  This could lead to copying
the chain multiple times (resulting in duplicate copies of the live tuple at
its end), or leaving dangling index entries behind (which, aside from
generating warnings from later vacuums, creates a risk of wrong query
results or bogus duplicate-key errors once the heap slot the index entry
points to is repopulated).

The fix is to recheck HeapTupleSatisfiesVacuum while following a chain
forward, and to stop if a DEAD tuple is reached.  Each contiguous group
of RECENTLY_DEAD tuples will therefore be copied as a separate chain.
The patch also adds a couple of extra sanity checks to verify correct
behavior.

Per report and test case from Pavan Deolasee.

18 years agoArrange to install a "posixrules" entry in our timezone database, so that
Tom Lane [Wed, 14 Mar 2007 17:38:29 +0000 (17:38 +0000)] 
Arrange to install a "posixrules" entry in our timezone database, so that
POSIX-style timezone specs that don't exactly match any database entry will
be treated as having correct USA DST rules.  Also, document that this can
be changed if you want to use some other DST rules with a POSIX zone spec.

We could consider changing localtime.c's TZDEFRULESTRING, but since that
facility can only deal with one DST transition rule, it seems fairly useless
now; might as well just plan to override it using a "posixrules" entry.

Backpatch as far as 8.0.  There isn't much we can do in 7.x ... either your
libc gets it right, or it doesn't.

18 years agoFix oversight in original coding of inline_function(): since
Tom Lane [Tue, 6 Mar 2007 22:45:35 +0000 (22:45 +0000)] 
Fix oversight in original coding of inline_function(): since
check_sql_fn_retval allows binary-compatibility cases, the expression
extracted from an inline-able SQL function might have a type that is only
binary-compatible with the declared function result type.  To avoid possibly
changing the semantics of the expression, we should insert a RelabelType node
in such cases.  This has only been shown to have bad consequences in recent
8.1 and up releases, but I suspect there may be failure cases in the older
branches too, so patch it all the way back.  Per bug #3116 from Greg Mullane.

Along the way, fix an omission in eval_const_expressions_mutator: it failed
to copy the relabelformat field when processing a RelabelType.  No known
observable failures from this, but it definitely isn't intended behavior.

18 years agoFix markQueryForLocking() to work correctly in the presence of nested views.
Tom Lane [Thu, 1 Mar 2007 18:50:49 +0000 (18:50 +0000)] 
Fix markQueryForLocking() to work correctly in the presence of nested views.
It has been wrong for this case since it was first written for 7.1 :-(
Per report from Pavel Hanák.

18 years agoBackported bug fix for #2956.
Michael Meskes [Tue, 27 Feb 2007 13:26:59 +0000 (13:26 +0000)] 
Backported bug fix for #2956.

18 years agoFix portal management code to support non-default command completion tags for
Tom Lane [Sun, 18 Feb 2007 19:49:42 +0000 (19:49 +0000)] 
Fix portal management code to support non-default command completion tags for
portals using PORTAL_UTIL_SELECT strategy.  This is currently significant only
for FETCH queries, which are supposed to include a count in the tag.  Seems
it's been broken since 7.4, but nobody noticed before Knut Lehre.

18 years agoFix backend crash in parsing incorrect tsquery.
Teodor Sigaev [Mon, 12 Feb 2007 14:18:43 +0000 (14:18 +0000)] 
Fix backend crash in parsing incorrect tsquery.

 Per report from Jon Rosebaugh <jon@inklesspen.com>

18 years agoFix an ancient logic error in plpgsql's exec_stmt_block: it thought it could
Tom Lane [Thu, 8 Feb 2007 18:38:08 +0000 (18:38 +0000)] 
Fix an ancient logic error in plpgsql's exec_stmt_block: it thought it could
get away with not (re)initializing a local variable if the variable is marked
"isconst" and not "isnull".  Unfortunately it makes this decision after having
already freed the old value, meaning that something like

   for i in 1..10 loop
     declare c constant text := 'hi there';

leads to subsequent accesses to freed memory, and hence probably crashes.
(In particular, this is why Asif Ali Rehman's bug leads to crash and not
just an unexpectedly-NULL value for SQLERRM: SQLERRM is marked CONSTANT
and so triggers this error.)

The whole thing seems wrong on its face anyway: CONSTANT means that you can't
change the variable inside the block, not that the initializer expression is
guaranteed not to change value across successive block entries.  Hence,
remove the "optimization" instead of trying to fix it.

18 years agoRearrange use of plpgsql_add_initdatums() so that only the parsing of a
Tom Lane [Thu, 8 Feb 2007 18:38:03 +0000 (18:38 +0000)] 
Rearrange use of plpgsql_add_initdatums() so that only the parsing of a
DECLARE section needs to know about it.  Formerly, everyplace besides DECLARE
that created variables needed to do "plpgsql_add_initdatums(NULL)" to prevent
those variables from being sucked up as part of a subsequent DECLARE block.
This is obviously error-prone, and in fact the SQLSTATE/SQLERRM patch had
failed to do it for those two variables, leading to the bug recently exhibited
by Asif Ali Rehman: a DECLARE within an exception handler tried to reinitialize
SQLERRM.

Although the SQLSTATE/SQLERRM patch isn't in any pre-8.1 branches, and so
I can't point to a demonstrable failure there, it seems wise to back-patch
this into the older branches anyway, just to keep the logic similar to HEAD.

18 years agoStamp releases notes for 8.2.3, 8.1.8, 8.0.12. REL8_0_12
Bruce Momjian [Wed, 7 Feb 2007 04:22:08 +0000 (04:22 +0000)] 
Stamp releases notes for 8.2.3, 8.1.8, 8.0.12.

18 years agoStamp releases 8.2.3, 8.1.8, 8.0.12. No release notes yet.
Bruce Momjian [Wed, 7 Feb 2007 03:48:21 +0000 (03:48 +0000)] 
Stamp releases 8.2.3, 8.1.8, 8.0.12.  No release notes yet.

18 years agoFix an error in the original coding of holdable cursors: PersistHoldablePortal
Tom Lane [Tue, 6 Feb 2007 22:49:42 +0000 (22:49 +0000)] 
Fix an error in the original coding of holdable cursors: PersistHoldablePortal
thought that it didn't have to reposition the underlying tuplestore if the
portal is atEnd.  But this is not so, because tuplestores have separate read
and write cursors ... and the read cursor hasn't moved from the start.
This mistake explains bug #2970 from William Zhang.

Note: the coding here is pretty inefficient, but given that no one has noticed
this bug until now, I'd say hardly anyone uses the case where the cursor has
been advanced before being persisted.  So maybe it's not worth worrying about.

18 years agoRemove typmod checking from the recent security-related patches. It turns
Tom Lane [Tue, 6 Feb 2007 17:35:41 +0000 (17:35 +0000)] 
Remove typmod checking from the recent security-related patches.  It turns
out that ExecEvalVar and friends don't necessarily have access to a tuple
descriptor with correct typmod: it definitely can contain -1, and possibly
might contain other values that are different from the Var's value.
Arguably this should be cleaned up someday, but it's not a simple change,
and in any case typmod discrepancies don't pose a security hazard.
Per reports from numerous people :-(

I'm not entirely sure whether the failure can occur in 8.0 --- the simple
test cases reported so far don't trigger it there.  But back-patch the
change all the way anyway.

18 years agoBackported va_list handling cleanup
Michael Meskes [Tue, 6 Feb 2007 09:42:08 +0000 (09:42 +0000)] 
Backported va_list handling cleanup

18 years agoReword suggestion that libpq.dll be installed in WINNT\SYSTEM32 under
Neil Conway [Fri, 2 Feb 2007 16:10:18 +0000 (16:10 +0000)] 
Reword suggestion that libpq.dll be installed in WINNT\SYSTEM32 under
Windows. Per Magnus Hagander, this is not recommended.

18 years agoStamp release 8.0.11. REL8_0_11
Tom Lane [Fri, 2 Feb 2007 00:15:09 +0000 (00:15 +0000)] 
Stamp release 8.0.11.

Security: CVE-2007-0555, CVE-2007-0556

18 years agoUpdate release notes for security-related releases in all active branches.
Tom Lane [Fri, 2 Feb 2007 00:10:51 +0000 (00:10 +0000)] 
Update release notes for security-related releases in all active branches.

Security: CVE-2007-0555, CVE-2007-0556

18 years agoRepair failure to check that a table is still compatible with a previously
Tom Lane [Fri, 2 Feb 2007 00:08:01 +0000 (00:08 +0000)] 
Repair failure to check that a table is still compatible with a previously
made query plan.  Use of ALTER COLUMN TYPE creates a hazard for cached
query plans: they could contain Vars that claim a column has a different
type than it now has.  Fix this by checking during plan startup that Vars
at relation scan level match the current relation tuple descriptor.  Since
at that point we already have at least AccessShareLock, we can be sure the
column type will not change underneath us later in the query.  However,
since a backend's locks do not conflict against itself, there is still a
hole for an attacker to exploit: he could try to execute ALTER COLUMN TYPE
while a query is in progress in the current backend.  Seal that hole by
rejecting ALTER TABLE whenever the target relation is already open in
the current backend.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0556

18 years agoRepair insufficiently careful type checking for SQL-language functions:
Tom Lane [Fri, 2 Feb 2007 00:03:44 +0000 (00:03 +0000)] 
Repair insufficiently careful type checking for SQL-language functions:
we should check that the function code returns the claimed result datatype
every time we parse the function for execution.  Formerly, for simple
scalar result types we assumed the creation-time check was sufficient, but
this fails if the function selects from a table that's been redefined since
then, and even more obviously fails if check_function_bodies had been OFF.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0555

18 years agoTranslation updates
Peter Eisentraut [Wed, 31 Jan 2007 08:20:42 +0000 (08:20 +0000)] 
Translation updates

18 years agoAdd SPI_push/SPI_pop calls so that datatype input and output functions called
Tom Lane [Tue, 30 Jan 2007 18:02:40 +0000 (18:02 +0000)] 
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.

18 years agoCorrect an old logic error in btree page splitting: when considering a split
Tom Lane [Sat, 27 Jan 2007 20:53:46 +0000 (20:53 +0000)] 
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.

18 years agoGet pg_utf_mblen(), pg_utf2wchar_with_len(), and utf2ucs() all on the same
Tom Lane [Wed, 24 Jan 2007 17:12:35 +0000 (17:12 +0000)] 
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.

18 years agoRelax an Assert() that has been found to be too strict in some situations
Tom Lane [Wed, 24 Jan 2007 01:26:02 +0000 (01:26 +0000)] 
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.

18 years agoBack port patch.
Tatsuo Ishii [Sat, 13 Jan 2007 03:17:34 +0000 (03:17 +0000)] 
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.

18 years agotag it REL8_0_10
PostgreSQL Daemon [Sat, 6 Jan 2007 06:18:46 +0000 (06:18 +0000)] 
tag it

18 years agoLinks to GUC variables from HISTORY don't work in back branches...
Tom Lane [Sat, 6 Jan 2007 06:01:48 +0000 (06:01 +0000)] 
Links to GUC variables from HISTORY don't work in back branches...

18 years agoFix markup because older releases couldn't link to the reference section.
Bruce Momjian [Sat, 6 Jan 2007 04:17:33 +0000 (04:17 +0000)] 
Fix markup because older releases couldn't link to the reference section.

18 years agoMinor copy-editing for release note updates.
Tom Lane [Fri, 5 Jan 2007 22:35:04 +0000 (22:35 +0000)] 
Minor copy-editing for release note updates.

18 years agoStamp release 8.0.10.
Bruce Momjian [Fri, 5 Jan 2007 20:53:30 +0000 (20:53 +0000)] 
Stamp release 8.0.10.

18 years agoCreate release notes for 8.0.10.
Bruce Momjian [Fri, 5 Jan 2007 20:03:19 +0000 (20:03 +0000)] 
Create release notes for 8.0.10.

18 years agoFix regex_fixed_prefix() to cope reasonably well with regex patterns of the
Tom Lane [Wed, 3 Jan 2007 22:39:49 +0000 (22:39 +0000)] 
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.

18 years agoRepair bug #2839: the various ExecReScan functions need to reset
Tom Lane [Tue, 26 Dec 2006 19:27:10 +0000 (19:27 +0000)] 
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.

18 years agoFix convertion for 'PFX flag N num'
Teodor Sigaev [Thu, 21 Dec 2006 17:36:08 +0000 (17:36 +0000)] 
Fix convertion for 'PFX flag N num'

18 years agoDocument the recently-understood hazard that a rollback can release row-level
Tom Lane [Fri, 1 Dec 2006 20:50:06 +0000 (20:50 +0000)] 
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...

18 years agoUpdate timezone data to tzdata2006p zic distribution. It seems Western
Tom Lane [Tue, 28 Nov 2006 19:37:23 +0000 (19:37 +0000)] 
Update timezone data to tzdata2006p zic distribution.  It seems Western
Australia decided to institute DST with one month's notice ... way to go,
politicians.

18 years agoMark to_number() and the numeric-type variants of to_char() as stable, not
Tom Lane [Tue, 28 Nov 2006 19:19:07 +0000 (19:19 +0000)] 
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.

18 years agoFix psql's \copy command to ensure that it cycles libpq back to the idle state
Tom Lane [Fri, 24 Nov 2006 23:07:01 +0000 (23:07 +0000)] 
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.

18 years agoFix 1-byte buffer overrun when OID exceeds 1 billion. This probably can't
Tom Lane [Wed, 22 Nov 2006 21:13:04 +0000 (21:13 +0000)] 
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.

18 years agoWhen truncating a relation in-place (eg during VACUUM), do not try to unlink
Tom Lane [Mon, 20 Nov 2006 01:08:10 +0000 (01:08 +0000)] 
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.

18 years agoRepair problems with hash indexes that span multiple segments: the hash code's
Tom Lane [Sun, 19 Nov 2006 21:33:37 +0000 (21:33 +0000)] 
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.

18 years agoApplied patch by Peter Harris to free auto_mem struct in ECPGconnect.
Michael Meskes [Wed, 8 Nov 2006 10:48:21 +0000 (10:48 +0000)] 
Applied patch by Peter Harris to free auto_mem struct in ECPGconnect.

18 years agoRepair bug #2694 concerning an ARRAY[] construct whose inputs are empty
Tom Lane [Mon, 6 Nov 2006 18:21:47 +0000 (18:21 +0000)] 
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.

18 years agoFix "failed to re-find parent key" btree VACUUM failure by tweaking
Tom Lane [Wed, 1 Nov 2006 19:50:08 +0000 (19:50 +0000)] 
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.

18 years agoBack-patch second version of AIX getaddrinfo fix.
Tom Lane [Fri, 20 Oct 2006 01:10:35 +0000 (01:10 +0000)] 
Back-patch second version of AIX getaddrinfo fix.

18 years agoWork around reported problem that AIX's getaddrinfo() doesn't seem to zero
Tom Lane [Thu, 19 Oct 2006 17:26:43 +0000 (17:26 +0000)] 
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.

18 years agoFix infinite sleep and failes of send in Win32.
Teodor Sigaev [Fri, 13 Oct 2006 14:00:41 +0000 (14:00 +0000)] 
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

18 years agoStamp 8.0.9. REL8_0_9
Tom Lane [Thu, 12 Oct 2006 19:41:43 +0000 (19:41 +0000)] 
Stamp 8.0.9.

18 years agoUpdate release notes for SQL functions vs triggers fix.
Tom Lane [Thu, 12 Oct 2006 19:25:32 +0000 (19:25 +0000)] 
Update release notes for SQL functions vs triggers fix.

18 years agoFix mishandling of after-trigger state when a SQL function returns multiple
Tom Lane [Thu, 12 Oct 2006 17:02:34 +0000 (17:02 +0000)] 
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.

18 years agoA bit of copy-editing on back-branch release notes.
Tom Lane [Wed, 11 Oct 2006 20:56:10 +0000 (20:56 +0000)] 
A bit of copy-editing on back-branch release notes.

18 years agoRepair incorrect check for coercion of unknown literal to ANYARRAY, a bug
Tom Lane [Wed, 11 Oct 2006 20:21:19 +0000 (20:21 +0000)] 
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.

18 years agoCREATE TABLE ... LIKE ... should mark the columns it creates with
Tom Lane [Wed, 11 Oct 2006 20:03:18 +0000 (20:03 +0000)] 
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.

18 years agoFix psql \d commands to behave properly when a pattern using regex | is given.
Tom Lane [Tue, 10 Oct 2006 16:15:28 +0000 (16:15 +0000)] 
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.

18 years agoStamp releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5.
Bruce Momjian [Mon, 9 Oct 2006 23:38:46 +0000 (23:38 +0000)] 
Stamp releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5.

18 years agoUpdate release notes for releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5.
Bruce Momjian [Mon, 9 Oct 2006 23:23:29 +0000 (23:23 +0000)] 
Update release notes for releases 7.3.16, 7.4.14, 8.0.9, and 8.1.5.

18 years agoFix back-branch pg_regress scripts to try the "canonical" expected file if we
Tom Lane [Mon, 9 Oct 2006 01:45:49 +0000 (01:45 +0000)] 
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.

18 years agoFix ancient oversight in psql's \d pattern processing code: when seeing two
Tom Lane [Sat, 7 Oct 2006 22:21:50 +0000 (22:21 +0000)] 
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 ...

18 years agoFix string_to_array() to correctly handle the case where there are
Tom Lane [Sat, 7 Oct 2006 00:12:05 +0000 (00:12 +0000)] 
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.

18 years agoFix SysCacheGetAttr() to handle the case where the specified syscache has not
Tom Lane [Fri, 6 Oct 2006 18:23:48 +0000 (18:23 +0000)] 
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.

18 years agodate_trunc also accepts 'quarter'. Noted by Yoshihisa Nakano.
Tom Lane [Sun, 1 Oct 2006 18:54:48 +0000 (18:54 +0000)] 
date_trunc also accepts 'quarter'.  Noted by Yoshihisa Nakano.

18 years agoClean up rather sloppy fix in HEAD for the ancient bug that CREATE CONVERSION
Tom Lane [Thu, 31 Aug 2006 17:31:48 +0000 (17:31 +0000)] 
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.

18 years agoFix mistyping
Teodor Sigaev [Tue, 29 Aug 2006 15:49:00 +0000 (15:49 +0000)] 
Fix mistyping