]> granicus.if.org Git - postgresql/log
postgresql
16 years agoSince the xmlagg section was moved, "below" is no longer accurate.
Peter Eisentraut [Thu, 13 Nov 2008 14:37:32 +0000 (14:37 +0000)]
Since the xmlagg section was moved, "below" is no longer accurate.

16 years agoIn predtest.c, install a limit on the number of branches we will process in
Tom Lane [Wed, 12 Nov 2008 23:08:42 +0000 (23:08 +0000)]
In predtest.c, install a limit on the number of branches we will process in
AND, OR, or equivalent clauses: if there are too many (more than 100) just
exit without proving anything.  This ensures that we don't spend O(N^2) time
trying (and most likely failing) to prove anything about very long IN lists
and similar cases.

Also, install a couple of CHECK_FOR_INTERRUPTS calls to ensure that a long
proof attempt can be interrupted.

Per gripe from Sergey Konoplev.

Back-patch the whole patch to 8.2 and just the CHECK_FOR_INTERRUPTS addition
to 8.1.  (The rest of the patch doesn't apply cleanly, and since 8.1 doesn't
show the complained-of behavior anyway, it doesn't seem necessary to work
hard on it.)

16 years agoFix off-by-one error in autovacuum shmem struct sizing. This could lead to
Heikki Linnakangas [Wed, 12 Nov 2008 10:10:43 +0000 (10:10 +0000)]
Fix off-by-one error in autovacuum shmem struct sizing. This could lead to
autovacuum worker sending SIGUSR1 signal to wrong process, per Zou Yong's
report.

Backpatch to 8.3.

16 years agoDetect and error out on inability to get proper linkage information required for...
Andrew Dunstan [Wed, 12 Nov 2008 00:00:29 +0000 (00:00 +0000)]
Detect and error out on inability to get proper linkage information required for plperl, usually due to absence of perl ExtUtils::Embed module. Backpatch as far as 8.1.

16 years agoMention the tup_fetched column in pg_stat_database.
Magnus Hagander [Tue, 11 Nov 2008 20:06:25 +0000 (20:06 +0000)]
Mention the tup_fetched column in pg_stat_database.

Greg Sabino Mullane

16 years agoGet rid of adjust_appendrel_attr_needed(), which has been broken ever since
Tom Lane [Tue, 11 Nov 2008 18:13:44 +0000 (18:13 +0000)]
Get rid of adjust_appendrel_attr_needed(), which has been broken ever since
we extended the appendrel mechanism to support UNION ALL optimization.  The
reason nobody noticed was that we are not actually using attr_needed data for
appendrel children; hence it seems more reasonable to rip it out than fix it.
Back-patch to 8.2 because an Assert failure is possible in corner cases.
Per examination of an example from Jim Nasby.

In HEAD, also get rid of AppendRelInfo.col_mappings, which is quite inadequate
to represent UNION ALL situations; depend entirely on translated_vars instead.

16 years agoFix bugs in sqlchar_to_unicode and unicode_to_sqlchar: both were measuring
Tom Lane [Mon, 10 Nov 2008 18:02:27 +0000 (18:02 +0000)]
Fix bugs in sqlchar_to_unicode and unicode_to_sqlchar: both were measuring
the length of a UTF8 character with pg_mblen (wrong if DB encoding isn't
UTF8), and the latter was blithely assuming that a static buffer would somehow
revert to all zeroes for each use.

16 years agoFix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
Tom Lane [Mon, 10 Nov 2008 14:57:46 +0000 (14:57 +0000)]
Fix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
it was using too soon.  In a situation where pg_do_encoding_conversion is
a no-op, this led to garbage data returned.

In HEAD, also modify the code that's ensuring null termination to make it
a tad more obvious what's happening.

16 years agoDocument that 'sslmode' is ignored for Unix domain socket communication;
Bruce Momjian [Tue, 4 Nov 2008 22:36:12 +0000 (22:36 +0000)]
Document that 'sslmode' is ignored for Unix domain socket communication;
backpatch to 8.3.X.

16 years agocommit for 8.3.5 REL8_3_5
Marc G. Fournier [Fri, 31 Oct 2008 02:38:34 +0000 (02:38 +0000)]
commit for 8.3.5

16 years agoUpdate back-branch release notes.
Tom Lane [Thu, 30 Oct 2008 22:22:41 +0000 (22:22 +0000)]
Update back-branch release notes.

16 years agoTranslation updates
Peter Eisentraut [Thu, 30 Oct 2008 21:30:20 +0000 (21:30 +0000)]
Translation updates

16 years agoRevert previous patch to put the shared memory segment on win32
Magnus Hagander [Thu, 30 Oct 2008 17:04:11 +0000 (17:04 +0000)]
Revert previous patch to put the shared memory segment on win32
in the Global\ namespace, because it caused permission errors on
a lot of platforms.

We need to come up with something better for 8.4, but for now
revert to the pre-8.3.4 behaviour.

16 years agoUpdate time zone data files to tzdata release 2008i (DST law changes in
Tom Lane [Thu, 30 Oct 2008 13:17:02 +0000 (13:17 +0000)]
Update time zone data files to tzdata release 2008i (DST law changes in
Argentina, Brazil, Mauritius, Syria).

16 years agoMissing space in error message
Peter Eisentraut [Thu, 30 Oct 2008 12:27:42 +0000 (12:27 +0000)]
Missing space in error message

16 years agoImprove new message
Peter Eisentraut [Thu, 30 Oct 2008 08:51:13 +0000 (08:51 +0000)]
Improve new message

16 years agoFix recoveryLastXTime logic so that it actually does what one would expect.
Tom Lane [Thu, 30 Oct 2008 04:06:25 +0000 (04:06 +0000)]
Fix recoveryLastXTime logic so that it actually does what one would expect.
Per gripe from Kevin Grittner.  Backpatch to 8.3, where the bug was introduced.

16 years agoInstall a more robust solution for the problem of infinite error-processing
Tom Lane [Mon, 27 Oct 2008 19:37:29 +0000 (19:37 +0000)]
Install a more robust solution for the problem of infinite error-processing
recursion when we are unable to convert a localized error message to the
client's encoding.  We've been over this ground before, but as reported by
Ibrar Ahmed, it still didn't work in the case of conversion failures for
the conversion-failure message itself :-(.  Fix by installing a "circuit
breaker" that disables attempts to localize this message once we get into
recursion trouble.

Patch all supported branches, because it is in fact broken in all of them;
though I had to add some missing translations to the older branches in
order to expose the failure in the particular test case I was using.

16 years agoBetter solution to the IN-list issue: instead of having an arbitrary cutoff,
Tom Lane [Sun, 26 Oct 2008 02:46:30 +0000 (02:46 +0000)]
Better solution to the IN-list issue: instead of having an arbitrary cutoff,
treat Var and non-Var IN-list items differently.  Only non-Var items are
candidates to go into an ANY(ARRAY) construct --- we put all Vars as separate
OR conditions on the grounds that that leaves more scope for optimization.
Per suggestion from Robert Haas.

16 years agoAdd a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
Tom Lane [Sat, 25 Oct 2008 17:19:17 +0000 (17:19 +0000)]
Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there
are Vars in the right-hand side.  This avoids a performance regression compared
to pre-8.2 releases, in cases where the OR form can be optimized into scans
of multiple indexes.  Limit the possible downside by preferring this form only
when the list isn't very long (I set the cutoff at 32 elements, which is a
bit arbitrary but in the right ballpark).  Per discussion with Jim Nasby.

In passing, also make it try the OR form if it cannot select a common type
for the array elements; we've seen a complaint or two about how the OR form
worked for such cases and ARRAY doesn't.

16 years agoFix an old bug in after-trigger handling: AfterTriggerEndQuery took the
Tom Lane [Sat, 25 Oct 2008 03:32:44 +0000 (03:32 +0000)]
Fix an old bug in after-trigger handling: AfterTriggerEndQuery took the
address of afterTriggers->query_stack[afterTriggers->query_depth] and hung
onto it through all its firings of triggers.  However, if a trigger causes
sufficiently many nested query executions, query_stack will get repalloc'd
bigger, leaving AfterTriggerEndQuery --- and hence afterTriggerInvokeEvents
--- using a stale pointer.

So far as I can find, the only consequence of this error is to stomp on a
couple of words of already-freed memory; which would lead to a failure only if
that chunk had already gotten re-allocated for something else.  So it's hard
to exhibit a simple failure case, but this is surely a bug.

I noticed this while working on my recent patch to reduce pending-trigger
space usage.  The present patch is mighty ugly, because it requires making
afterTriggerInvokeEvents know about all the possible event lists it might get
called on.  Fortunately, this is only needed in back branches because CVS HEAD
avoids the problem in a different way: afterTriggerInvokeEvents only touches
the passed AfterTriggerEventList pointer once at startup.  Back branches are
stable enough that wiring in knowledge of all possible call usages doesn't
seem like a killer problem.

Back-patch to 8.0.  7.4's trigger code is completely different and doesn't
seem to have the problem (it doesn't even use repalloc).

16 years agoFix memory leak when using gsslib parameter in libpq connections
Magnus Hagander [Thu, 23 Oct 2008 16:17:22 +0000 (16:17 +0000)]
Fix memory leak when using gsslib parameter in libpq connections

16 years agoOn second thought, let's not get involved in correcting the feature list
Peter Eisentraut [Thu, 23 Oct 2008 11:12:56 +0000 (11:12 +0000)]
On second thought, let's not get involved in correcting the feature list
in 8.3.  The list is quite outdated, and fixing it up would require more
effort.  Plus, we don't want diverging information schema contents.

16 years agoFix GiST's killing tuple: GISTScanOpaque->curpos wasn't
Teodor Sigaev [Wed, 22 Oct 2008 12:54:25 +0000 (12:54 +0000)]
Fix GiST's killing tuple: GISTScanOpaque->curpos wasn't
correctly set. As result, killtuple() marks as dead
wrong tuple on page. Bug was introduced by me while fixing
possible duplicates during GiST index scan.

16 years agoSmall correction SQL feature table
Peter Eisentraut [Fri, 17 Oct 2008 23:21:09 +0000 (23:21 +0000)]
Small correction SQL feature table

16 years agoFix small bug in headline generation.
Teodor Sigaev [Fri, 17 Oct 2008 17:32:59 +0000 (17:32 +0000)]
Fix small bug in headline generation.
Patch from Sushant Sinha <sushant354@gmail.com>
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00785.php

16 years agoDuring repeated rescan of GiST index it's possible that scan key
Teodor Sigaev [Fri, 17 Oct 2008 17:02:42 +0000 (17:02 +0000)]
During repeated rescan of GiST index it's possible that scan key
is NULL but SK_SEARCHNULL is not set. Add checking IS NULL of keys
to set during key initialization. If key is NULL and SK_SEARCHNULL is not
set then nothnig can be satisfied.
With assert-enabled compilation that causes coredump.

Bug was introduced in 8.3 by support of IS NULL index scan.

16 years agoFix a small memory leak in ExecReScanAgg() in the hashed aggregation case.
Neil Conway [Thu, 16 Oct 2008 19:25:58 +0000 (19:25 +0000)]
Fix a small memory leak in ExecReScanAgg() in the hashed aggregation case.
In the previous coding, the list of columns that needed to be hashed on
was allocated in the per-query context, but we reallocated every time
the Agg node was rescanned. Since this information doesn't change over
a rescan, just construct the list of columns once during ExecInitAgg().

16 years agoFix SPI_getvalue and SPI_getbinval to range-check the given attribute number
Tom Lane [Thu, 16 Oct 2008 13:23:28 +0000 (13:23 +0000)]
Fix SPI_getvalue and SPI_getbinval to range-check the given attribute number
according to the TupleDesc's natts, not the number of physical columns in the
tuple.  The previous coding would do the wrong thing in cases where natts is
different from the tuple's column count: either incorrectly report error when
it should just treat the column as null, or actually crash due to indexing off
the end of the TupleDesc's attribute array.  (The second case is probably not
possible in modern PG versions, due to more careful handling of inheritance
cases than we once had.  But it's still a clear lack of robustness here.)

The incorrect error indication is ignored by all callers within the core PG
distribution, so this bug has no symptoms visible within the core code, but
it might well be an issue for add-on packages.  So patch all the way back.

16 years agoFix COPY documentation to not imply that HEADER can be used outside CSV mode.
Tom Lane [Fri, 10 Oct 2008 21:46:43 +0000 (21:46 +0000)]
Fix COPY documentation to not imply that HEADER can be used outside CSV mode.
Per gripe from Bill Thoen.

16 years agoFix omission of DiscardStmt in GetCommandLogLevel, per report from Hubert
Tom Lane [Fri, 10 Oct 2008 13:48:12 +0000 (13:48 +0000)]
Fix omission of DiscardStmt in GetCommandLogLevel, per report from Hubert
Depesz Lubaczewski.  In HEAD, also move a couple of other cases to make the
code ordering match up with ProcessUtility.

16 years agoOptional arguments should be optional.
Michael Meskes [Fri, 10 Oct 2008 12:20:06 +0000 (12:20 +0000)]
Optional arguments should be optional.

16 years agoFix overly tense optimization of PLpgSQL_func_hashkey: we must represent
Tom Lane [Thu, 9 Oct 2008 16:35:13 +0000 (16:35 +0000)]
Fix overly tense optimization of PLpgSQL_func_hashkey: we must represent
the isTrigger state explicitly, not rely on nonzero-ness of trigrelOid
to indicate trigger-hood, because trigrelOid will be left zero when compiling
for validation.  The (useless) function hash entry built by the validator
was able to match an ordinary non-trigger call later in the same session,
thereby bypassing the check that is supposed to prevent such a call.
Per report from Alvaro.

It might be worth suppressing the useless hash entry altogether, but
that's a bigger change than I want to consider back-patching.

Back-patch to 8.0.  7.4 doesn't have the problem because it doesn't
have validation mode.

16 years agoFix crash in bytea-to-XML mapping when the source value is toasted.
Tom Lane [Thu, 9 Oct 2008 15:49:10 +0000 (15:49 +0000)]
Fix crash in bytea-to-XML mapping when the source value is toasted.
Report and fix by Michael McMaster.  Some minor code beautification by me,
also avoid memory leaks in the special-case paths.

16 years agoForce a checkpoint in CREATE DATABASE before starting to copy the files,
Heikki Linnakangas [Thu, 9 Oct 2008 10:34:22 +0000 (10:34 +0000)]
Force a checkpoint in CREATE DATABASE before starting to copy the files,
to process any pending unlinks for the source database.

Before, if you dropped a relation in the template database just before
CREATE DATABASE, and a checkpoint happened during copydir(), the checkpoint
might delete a file that we're just about to copy, causing lstat() in
copydir() to fail with ENOENT.

Backpatch to 8.3, where the pending unlinks were introduced.

Per report by Matthew Wakeling and analysis by Tom Lane.

16 years agoWhen a relation is moved to another tablespace, we can't assume that we can
Heikki Linnakangas [Tue, 7 Oct 2008 11:15:48 +0000 (11:15 +0000)]
When a relation is moved to another tablespace, we can't assume that we can
use the old relfilenode in the new tablespace. There might be another relation
in the new tablespace with the same relfilenode, so we must generate a fresh
relfilenode in the new tablespace.

The 8.3 patch to let deleted relation files linger as zero-length files until
the next checkpoint made this more obvious: moving a relation from one table
space another, and then back again, caused a collision with the lingering
file.

Back-patch to 8.1. The issue is present in 8.0 as well, but it doesn't seem
worth fixing there, because we didn't have protection from OID collisions
after OID wraparound before 8.1.

Report by Guillaume Lelarge.

16 years agoFix improper display of fractional seconds in interval values
Tom Lane [Thu, 2 Oct 2008 13:47:44 +0000 (13:47 +0000)]
Fix improper display of fractional seconds in interval values
when using --enable-integer-datetimes and a non-ISO datestyle.

Ron Mayer

16 years agoLink libpq with libgssapi if configure finds it, as
Magnus Hagander [Wed, 1 Oct 2008 15:35:34 +0000 (15:35 +0000)]
Link libpq with libgssapi if configure finds it, as
required by at least NetBSD.

Markus Schaaf

16 years agoRecent patches to pg_ctl broke "pg_ctl restart" for the case where no
Tom Lane [Tue, 30 Sep 2008 13:14:07 +0000 (13:14 +0000)]
Recent patches to pg_ctl broke "pg_ctl restart" for the case where no
command-line options had been given to the postmaster; and just plain
broke it altogether in 8.1 and 8.0.  Per report from KaiGai Kohei.

16 years agoCompare escaped chars case insensitively for ILIKE - per gripe from TGL.
Andrew Dunstan [Sat, 27 Sep 2008 16:57:43 +0000 (16:57 +0000)]
Compare escaped chars case insensitively for ILIKE - per gripe from TGL.

16 years agoFix more problems with rewriter failing to set Query.hasSubLinks when inserting
Tom Lane [Wed, 24 Sep 2008 16:52:53 +0000 (16:52 +0000)]
Fix more problems with rewriter failing to set Query.hasSubLinks when inserting
a SubLink expression into a rule query.  We missed cases where the original
query contained a sub-SELECT in a function in FROM, a multi-row VALUES list,
or a RETURNING list.  Per bug #4434 from Dean Rasheed and subsequent
investigation.

Back-patch to 8.1; older releases don't have the issue because they didn't
try to be smart about setting hasSubLinks only when needed.

16 years agoMake sure pg_control is opened in binary mode, to deal
Magnus Hagander [Wed, 24 Sep 2008 08:59:46 +0000 (08:59 +0000)]
Make sure pg_control is opened in binary mode, to deal
with situtations when the file contains an EOF maker
(0x1A) on Windows.

ITAGAKI Takahiro

16 years agoMark SessionReplicationRole as PGDLLIMPORT so it
Magnus Hagander [Fri, 19 Sep 2008 14:43:47 +0000 (14:43 +0000)]
Mark SessionReplicationRole as PGDLLIMPORT so it
can be used from Slony functions.

Per report from Hiroshi Saito.

16 years agotag for 8.3.4 REL8_3_4
Marc G. Fournier [Fri, 19 Sep 2008 03:04:13 +0000 (03:04 +0000)]
tag for 8.3.4

16 years agoUpdate back-branch release notes.
Tom Lane [Fri, 19 Sep 2008 02:45:21 +0000 (02:45 +0000)]
Update back-branch release notes.

16 years agoUpdate time zone data files to tzdata release 2008f (DST law changes in
Tom Lane [Wed, 17 Sep 2008 14:18:46 +0000 (14:18 +0000)]
Update time zone data files to tzdata release 2008f (DST law changes in
Argentina, Bahamas, Brazil, Mauritius, Morocco, Pakistan, Palestine, Paraguay).

16 years agoWiden the nLocks counts in local lock tables from int to int64. This
Tom Lane [Tue, 16 Sep 2008 01:56:35 +0000 (01:56 +0000)]
Widen the nLocks counts in local lock tables from int to int64.  This
forestalls potential overflow when the same table (or other object, but
usually tables) is accessed by very many successive queries within a single
transaction.  Per report from Michael Milligan.

Back-patch to 8.0, which is as far back as the patch conveniently applies.
There have been no reports of overflow in pre-8.3 releases, but clearly the
risk existed all along.  (Michael's report suggests that 8.3 may consume lock
counts faster than prior releases, but with no test case to look at it's hard
to be sure about that.  Widening the counts seems a good future-proofing
measure in any event.)

16 years agoFix multiple memory leaks in xml_out(). Per report from Matt Magoffin.
Tom Lane [Tue, 16 Sep 2008 00:49:49 +0000 (00:49 +0000)]
Fix multiple memory leaks in xml_out().  Per report from Matt Magoffin.

16 years agoFix caching of foreign-key-checking queries so that when a replan is needed,
Tom Lane [Mon, 15 Sep 2008 23:37:49 +0000 (23:37 +0000)]
Fix caching of foreign-key-checking queries so that when a replan is needed,
we regenerate the SQL query text not merely the plan derived from it.  This
is needed to handle contingencies such as renaming of a table or column
used in an FK.  Pre-8.3, such cases worked despite the lack of replanning
(because the cached plan needn't actually change), so this is a regression.
Per bug #4417 from Benjamin Bihler.

16 years agoSkip opfamily check in eclass_matches_any_index() when the index isn't a
Tom Lane [Fri, 12 Sep 2008 14:56:19 +0000 (14:56 +0000)]
Skip opfamily check in eclass_matches_any_index() when the index isn't a
btree.  We can't easily tell whether clauses generated from the equivalence
class could be used with such an index, so just assume that they might be.
This bit of over-optimization prevented use of non-btree indexes for nestloop
inner indexscans, in any case where the join uses an equality operator that
is also a btree operator --- which in particular is typically true for hash
indexes.  Noted while trying to test the current hash index patch.

16 years agoInitialize the minimum frozen Xid in vac_update_datfrozenxid using
Alvaro Herrera [Thu, 11 Sep 2008 14:01:35 +0000 (14:01 +0000)]
Initialize the minimum frozen Xid in vac_update_datfrozenxid using
GetOldestXmin() instead of RecentGlobalXmin; this is safer because we do not
depend on the latter being correctly set elsewhere, and while it is more
expensive, this code path is not performance-critical.  This is a real
risk for autovacuum, because it can execute whole cycles without doing
a single vacuum, which would mean that RecentGlobalXmin would stay at its
initialization value, FirstNormalTransactionId, causing a bogus value to be
inserted in pg_database.  This bug could explain some recent reports of
failure to truncate pg_clog.

At the same time, change the initialization of RecentGlobalXmin to
InvalidTransactionId, and ensure that it's set to something else whenever
it's going to be used.  Using it as FirstNormalTransactionId in HOT page
pruning could incur in data loss.  InitPostgres takes care of setting it
to a valid value, but the extra checks are there to prevent "special"
backends from behaving in unusual ways.

Per Tom Lane's detailed problem dissection in 29544.1221061979@sss.pgh.pa.us

16 years agoAvoid using sprintf() for a simple octal conversion in PQescapeByteaInternal.
Tom Lane [Wed, 10 Sep 2008 17:01:17 +0000 (17:01 +0000)]
Avoid using sprintf() for a simple octal conversion in PQescapeByteaInternal.
Improves performance, per suggestion from Rudolf Leitgeb (bug #4414).
The backend did this right already, but not libpq.

16 years agoFix plpgsql's exec_move_row() to supply valid type OIDs to exec_assign_value()
Tom Lane [Mon, 1 Sep 2008 22:30:40 +0000 (22:30 +0000)]
Fix plpgsql's exec_move_row() to supply valid type OIDs to exec_assign_value()
whenever possible, as per bug report from Oleg Serov.  While at it, reorder
the operations in the RECORD case to avoid possible palloc failure while the
variable update is only partly complete.

Back-patch as far as 8.1.  Although the code of the particular function is
similar in 8.0, 8.0's support for composite fields in rows is sufficiently
broken elsewhere that it doesn't seem worth fixing this.

16 years agoHeapTupleHeaderAdjustCmax made the incorrect assumption that the raw
Heikki Linnakangas [Mon, 1 Sep 2008 18:53:03 +0000 (18:53 +0000)]
HeapTupleHeaderAdjustCmax made the incorrect assumption that the raw
command id is the cmin, when it can in fact be a combo cid. That made rows
incorrectly invisible to a transaction where a tuple was deleted by multiple
aborted subtransactions.

Report and patch Karl Schnaitter. Back-patch to 8.3, where combo cids was
introduced.

16 years agoFix bug in original implementation of xmlserialize(): if user specifies
Tom Lane [Fri, 29 Aug 2008 17:27:50 +0000 (17:27 +0000)]
Fix bug in original implementation of xmlserialize(): if user specifies
a target type that isn't acceptable, the code failed to raise the proper
error.  The result instead was to return a NULL expression tree, which
in a quick test led to a 'cache lookup failed for type 0' error later.

Patch 8.3 only --- I fixed this in HEAD as part of recent locations patch.

16 years agoTeach eval_const_expressions() to simplify an ArrayCoerceExpr to a constant
Tom Lane [Tue, 26 Aug 2008 02:16:39 +0000 (02:16 +0000)]
Teach eval_const_expressions() to simplify an ArrayCoerceExpr to a constant
when its input is constant and the element coercion function is immutable
(or nonexistent, ie, binary-coercible case).  This is an oversight in the
8.3 implementation of ArrayCoerceExpr, and its result is that certain cases
involving IN or NOT IN with constants don't get optimized as they should be.
Per experimentation with an example from Ow Mun Heng.

16 years agoFix pg_dump docs to acknowledge that you can use -Z with plain text output. Pointed...
Tom Lane [Tue, 26 Aug 2008 00:03:24 +0000 (00:03 +0000)]
Fix pg_dump docs to acknowledge that you can use -Z with plain text output.  Pointed out by Daniel Migowski.

16 years agoFix possible duplicate tuples while GiST scan. Now page is processed
Teodor Sigaev [Sat, 23 Aug 2008 10:40:03 +0000 (10:40 +0000)]
Fix possible duplicate tuples while  GiST scan. Now page is processed
at once and ItemPointers are collected in memory.

Remove tuple's killing by killtuple() if tuple was moved to another
page - it could produce unaceptable overhead.

Backpatch up to 8.1 because the bug was introduced by GiST's concurrency support.

16 years agoMention that pg_dump does not dump ALTER DATABASE ... SET commands;
Bruce Momjian [Thu, 21 Aug 2008 22:26:12 +0000 (22:26 +0000)]
Mention that pg_dump does not dump ALTER DATABASE ... SET commands;
backpatch to 8.3.X. Also fix markup that had just one bullet.

16 years agoFixed incorrect argument handling in SET command if argument is a variable.
Michael Meskes [Wed, 20 Aug 2008 14:07:16 +0000 (14:07 +0000)]
Fixed incorrect argument handling in SET command if argument is a variable.

16 years agoMake libpq on windows not try to send chunks larger than 64Kb.
Magnus Hagander [Wed, 20 Aug 2008 11:53:51 +0000 (11:53 +0000)]
Make libpq on windows not try to send chunks larger than 64Kb.

Per Microsoft knowledge base article Q201213, early versions of
Windows fail when we do this. Later versions of Windows appear
to have a higher limit than 64Kb, but do still fail on large
sends, so we unconditionally limit it for all versions.

Patch from Tom Lane.

16 years agoFix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec
Tom Lane [Sat, 16 Aug 2008 02:25:11 +0000 (02:25 +0000)]
Fix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec
returns NULL instead of a PGresult.  The former coding would fail, which
is OK, but it neglected to give you the PQerrorMessage that might tell
you why.  In the oldest branches, there was another problem: it'd sometimes
report PQerrorMessage from the wrong connection.

16 years agoSynchronize Borland libpq makefile to match MSVC. Backpatch to 8.3.X.
Bruce Momjian [Sat, 16 Aug 2008 01:56:25 +0000 (01:56 +0000)]
Synchronize Borland libpq makefile to match MSVC.  Backpatch to 8.3.X.

16 years agoFix pull_up_simple_union_all to copy all rtable entries from child subquery to
Heikki Linnakangas [Thu, 14 Aug 2008 20:31:59 +0000 (20:31 +0000)]
Fix pull_up_simple_union_all to copy all rtable entries from child subquery to
parent, not only those with RangeTblRefs. We need them in ExecCheckRTPerms.

Report by Brendan O'Shea. Back-patch to 8.2, where pull_up_simple_union_all
was introduced.

16 years agoFix corner-case bug introduced with HOT: if REINDEX TABLE pg_class (or a
Tom Lane [Sun, 10 Aug 2008 19:02:46 +0000 (19:02 +0000)]
Fix corner-case bug introduced with HOT: if REINDEX TABLE pg_class (or a
REINDEX DATABASE including same) is done before a session has done any other
update on pg_class, the pg_class relcache entry was left with an incorrect
setting of rd_indexattr, because the indexed-attributes set would be first
demanded at a time when we'd forced a partial list of indexes into the
pg_class entry, and it would remain cached after that.  This could result
in incorrect decisions about HOT-update safety later in the same session.
In practice, since only pg_class_relname_nsp_index would be missed out,
only ALTER TABLE RENAME and ALTER TABLE SET SCHEMA could trigger a problem.
Per report and test case from Ondrej Jirman.

16 years agoInstall checks in executor startup to ensure that the tuples produced by an
Tom Lane [Fri, 8 Aug 2008 17:01:18 +0000 (17:01 +0000)]
Install checks in executor startup to ensure that the tuples produced by an
INSERT or UPDATE will match the target table's current rowtype.  In pre-8.3
releases inconsistency can arise with stale cached plans, as reported by
Merlin Moncure.  (We patched the equivalent hazard on the SELECT side in Feb
2007; I'm not sure why we thought there was no risk on the insertion side.)
In 8.3 and HEAD this problem should be impossible due to plan cache
invalidation management, but it seems prudent to make the check anyway.

Back-patch as far as 8.0.  7.x versions lack ALTER COLUMN TYPE, so there
seems no way to abuse a stale plan comparably.

16 years agoDo not allow Unique nodes to be scanned backwards. The code claimed that it
Tom Lane [Tue, 5 Aug 2008 21:28:36 +0000 (21:28 +0000)]
Do not allow Unique nodes to be scanned backwards.  The code claimed that it
would work, but in fact it didn't return the same rows when moving backwards
as when moving forwards.  This would have no visible effect in a DISTINCT
query (at least assuming the column datatypes use a strong definition of
equality), but it gave entirely wrong answers for DISTINCT ON queries.

16 years agoFix copy-and-pasteo that's causing pg_regress to lie about which file it can't
Tom Lane [Sun, 3 Aug 2008 05:12:45 +0000 (05:12 +0000)]
Fix copy-and-pasteo that's causing pg_regress to lie about which file it can't
read when the --temp-config argument is bad.  Noted while wondering why
buildfarm member dungbeetle is failing ... this isn't why, but it is why
the error report isn't very helpful ...

16 years agoCleanup reference to config.pl so it makes sense not only in
Magnus Hagander [Tue, 29 Jul 2008 15:23:46 +0000 (15:23 +0000)]
Cleanup reference to config.pl so it makes sense not only in
SGML source but in the actual web/pdf viewer...

16 years agoDocument which versions of ActivePerl and ActiveTcl are required
Magnus Hagander [Tue, 29 Jul 2008 15:17:29 +0000 (15:17 +0000)]
Document which versions of ActivePerl and ActiveTcl are required
for building on MSVC, and that the free distribution is enough
(no need for the enterprise version).

Per gripe from Martin Zaun.

16 years agoFix parsing of LDAP URLs so it doesn't reject spaces in the "suffix" part.
Tom Lane [Thu, 24 Jul 2008 17:52:02 +0000 (17:52 +0000)]
Fix parsing of LDAP URLs so it doesn't reject spaces in the "suffix" part.
Per report from César Miguel Oliveira Alves.

16 years agoRatchet up patch to improve autovacuum wraparound messages.
Alvaro Herrera [Wed, 23 Jul 2008 20:21:04 +0000 (20:21 +0000)]
Ratchet up patch to improve autovacuum wraparound messages.

Simon Riggs

16 years agoUpdate link to Oleg and Teodor's GIN page.
Tom Lane [Tue, 22 Jul 2008 22:05:34 +0000 (22:05 +0000)]
Update link to Oleg and Teodor's GIN page.
(Extracted from fast-insert patch, since it ought to be back-patched)

16 years agoPublish more openly the fact that autovacuum is working for wraparound
Alvaro Herrera [Mon, 21 Jul 2008 15:27:08 +0000 (15:27 +0000)]
Publish more openly the fact that autovacuum is working for wraparound
protection.

Simon Riggs

16 years agoProperly document archive/restore command examples on Windows.
Bruce Momjian [Fri, 18 Jul 2008 17:33:40 +0000 (17:33 +0000)]
Properly document archive/restore command examples on Windows.

ITAGAKI Takahiro

16 years agoAdd MSVC++ debug libraries to .cvsignore.
Alvaro Herrera [Thu, 17 Jul 2008 21:16:24 +0000 (21:16 +0000)]
Add MSVC++ debug libraries to .cvsignore.

16 years agoAvoid crashing when a table is deleted while we're on the process of checking
Alvaro Herrera [Thu, 17 Jul 2008 21:02:41 +0000 (21:02 +0000)]
Avoid crashing when a table is deleted while we're on the process of checking
it.  This is a stripped down version of the patch applied to HEAD.

Per report from Tom Lane based on buildfarm evidence.

17 years agoFix an oversight in the original implementation of performMultipleDeletions():
Tom Lane [Fri, 11 Jul 2008 16:08:50 +0000 (16:08 +0000)]
Fix an oversight in the original implementation of performMultipleDeletions():
the alreadyDeleted list has to be passed down through
deleteDependentObjects(), else objects that are deleted via auto/internal
dependencies don't get reported back up to performMultipleDeletions().
Depending on the visitation order, this could cause the code to try to delete
an already-deleted object, leading to strange errors in DROP OWNED (typically
"cache lookup failed for relation NNNNN" or similar).  Per bug #4289.

Patch for back branches only.  This code has recently been rewritten in HEAD,
and doesn't have this particular bug anymore.

17 years agoFix mis-calculation of extParam/allParam sets for plan nodes, as seen in
Tom Lane [Thu, 10 Jul 2008 01:17:36 +0000 (01:17 +0000)]
Fix mis-calculation of extParam/allParam sets for plan nodes, as seen in
bug #4290.  The fundamental bug is that masking extParam by outer_params,
as finalize_plan had been doing, caused us to lose the information that
an initPlan depended on the output of a sibling initPlan.  On reflection
the best thing to do seemed to be not to try to adjust outer_params for
this case but get rid of it entirely.  The only thing it was really doing
for us was to filter out param IDs associated with SubPlan nodes, and that
can be done (with greater accuracy) while processing individual SubPlan
nodes in finalize_primnode.  This approach was vindicated by the discovery
that the masking method was hiding a second bug: SS_finalize_plan failed to
remove extParam bits for initPlan output params that were referenced in the
main plan tree (it only got rid of those referenced by other initPlans).
It's not clear that this caused any real problems, given the limited use
of extParam by the executor, but it's certainly not what was intended.

I originally thought that there was also a problem with needing to include
indirect dependencies on external params in initPlans' param sets, but it
turns out that the executor handles this correctly so long as the depended-on
initPlan is earlier in the initPlans list than the one using its output.
That seems a bit of a fragile assumption, but it is true at the moment,
so I just documented it in some code comments rather than making what would
be rather invasive changes to remove the assumption.

Back-patch to 8.1.  Previous versions don't have the case of initPlans
referring to other initPlans' outputs, so while the existing logic is still
questionable for them, there are not any known bugs to be fixed.  So I'll
refrain from changing them for now.

17 years agoFix performance bug in write_syslog(): the code to preferentially break the
Tom Lane [Tue, 8 Jul 2008 22:17:47 +0000 (22:17 +0000)]
Fix performance bug in write_syslog(): the code to preferentially break the
log message at newlines cost O(N^2) for very long messages with few or no
newlines.  For messages in the megabyte range this became the dominant cost.
Per gripe from Achilleas Mantzios.

Patch all the way back, since this is a safe change with no portability
risks.  I am also thinking of increasing PG_SYSLOG_LIMIT, but that should
be done separately.

17 years agoFix WAL file cutoff point calculation in pg_standby.
Heikki Linnakangas [Tue, 8 Jul 2008 15:12:04 +0000 (15:12 +0000)]
Fix WAL file cutoff point calculation in pg_standby.

Patch by Simon Riggs, per bug report from Ferenc Felhoffer

17 years agoFix estimate_num_groups() to assume that GROUP BY expressions yielding boolean
Tom Lane [Mon, 7 Jul 2008 20:25:06 +0000 (20:25 +0000)]
Fix estimate_num_groups() to assume that GROUP BY expressions yielding boolean
results always contribute two groups, regardless of the expression contents.
This is very substantially more accurate than the regular heuristic for
certain boolean tests like "col IS NULL".  Per gripe from Sam Mason.

Back-patch to all supported releases, since the behavior of
estimate_num_groups() hasn't changed all that much since 7.4.

17 years agoFix AT TIME ZONE (in all three variants) so that we first try to interpret
Tom Lane [Mon, 7 Jul 2008 18:09:53 +0000 (18:09 +0000)]
Fix AT TIME ZONE (in all three variants) so that we first try to interpret
the timezone argument as a timezone abbreviation, and only try it as a full
timezone name if that fails.  The zic database has four zones (CET, EET, MET,
WET) that are full daylight-savings zones and yet have names that are the
same as their abbreviations for standard time, resulting in ambiguity.
In the timestamp input functions we resolve the ambiguity by preferring the
abbreviation, and AT TIME ZONE should work the same way.  (No functionality
is lost because the zic database also has other names for these zones, eg
Europe/Zurich.)  Per gripe from Jaromir Talir.

Backpatch to 8.1.  Older releases did not have the issue because AT TIME ZONE
only accepted abbreviations not zone names.  (Thus, this patch also arguably
fixes a compatibility botch introduced at 8.1: in ambiguous cases we now
behave the same as 8.0 did.)

17 years agoAdded documentation for xmlagg function.
Peter Eisentraut [Mon, 7 Jul 2008 15:55:28 +0000 (15:55 +0000)]
Added documentation for xmlagg function.

17 years agoPrevent integer overflows during units conversion when displaying a GUC
Tom Lane [Sun, 6 Jul 2008 19:48:53 +0000 (19:48 +0000)]
Prevent integer overflows during units conversion when displaying a GUC
variable that has units.  Per report from Stefan Kaltenbrunner.

Backport to 8.2.  I also backported my patch of 2007-06-21 that prevented
comparable overflows on the input side, since that now seems to have enough
field track record to be back-patched safely.  That patch included addition
of hints listing the available unit names, which I did not bother to strip
out of it --- this will make a little more work for the translators, but
they can copy the translation from 8.3, and anyway an untranslated hint
is better than no hint.

17 years agoFix a couple of bugs in win32 shmem name generation:
Magnus Hagander [Fri, 4 Jul 2008 10:50:20 +0000 (10:50 +0000)]
Fix a couple of bugs in win32 shmem name generation:
* Don't cut off the prefix. With this fix, it's again readable.
* Properly store it in the Global namespace as intended.

17 years agoFix transaction-lifespan memory leak in xpath(). Report by Matt Magoffin,
Tom Lane [Thu, 3 Jul 2008 00:04:34 +0000 (00:04 +0000)]
Fix transaction-lifespan memory leak in xpath().  Report by Matt Magoffin,
fix by Kris Jurka.

17 years agoFix identify_system_timezone() so that it tests the behavior of the system
Tom Lane [Tue, 1 Jul 2008 03:41:01 +0000 (03:41 +0000)]
Fix identify_system_timezone() so that it tests the behavior of the system
timezone setting in the current year and for 100 years back, rather than
always examining years 1904-2004.  The original coding would have problems
distinguishing zones whose behavior diverged only after 2004; which is a
situation we will surely face sometime, if it's not out there already.

In passing, also prevent selection of the dummy "Factory" timezone, even
if that's exactly what the system is using.  Reporting time as GMT seems
better than that.

17 years agoConsider a clause to be outerjoin_delayed if it references the nullable side
Tom Lane [Fri, 27 Jun 2008 20:54:45 +0000 (20:54 +0000)]
Consider a clause to be outerjoin_delayed if it references the nullable side
of any lower outer join, even if it also references the non-nullable side and
so could not get pushed below the outer join anyway.  We need this in case
the clause is an OR clause: if it doesn't get marked outerjoin_delayed,
create_or_index_quals() could pull an indexable restriction for the nullable
side out of it, leading to wrong results as demonstrated by today's bug
report from toruvinn.  (See added regression test case for an example.)

In principle this has been wrong for quite a while.  In practice I don't
think any branch before 8.3 can really show the failure, because
create_or_index_quals() will only pull out indexable conditions, and before
8.3 those were always strict.  So though we might have improperly generated
null-extended rows in the outer join, they'd get discarded from the result
anyway.  The gating factor that makes the failure visible is that 8.3
considers "col IS NULL" to be indexable.  Hence I'm not going to risk
back-patching further than 8.3.

17 years agoFix standalone libpq build on win32.
Magnus Hagander [Fri, 27 Jun 2008 18:58:16 +0000 (18:58 +0000)]
Fix standalone libpq build on win32.

Hiroshi Saito

17 years agoFix 'pg_ctl reload' to properly preserve postmaster commend-line
Bruce Momjian [Fri, 27 Jun 2008 01:53:31 +0000 (01:53 +0000)]
Fix 'pg_ctl reload' to properly preserve postmaster commend-line
arguments on restart.  Patch to releases 8.0 - 8.3.X.

17 years agoFix a few places that were non-multibyte-safe in tsearch configuration file
Tom Lane [Thu, 19 Jun 2008 16:52:31 +0000 (16:52 +0000)]
Fix a few places that were non-multibyte-safe in tsearch configuration file
parsing.  Per bug #4253 from Giorgio Valoti.

17 years agoImprove error reporting for problems in text search configuration files
Tom Lane [Wed, 18 Jun 2008 20:55:49 +0000 (20:55 +0000)]
Improve error reporting for problems in text search configuration files
by installing an error context subroutine that will provide the file name
and line number for all errors detected while reading a config file.
Some of the reader routines were already doing that in an ad-hoc way for
errors detected directly in the reader, but it didn't help for problems
detected in subroutines, such as encoding violations.

Back-patch to 8.3 because 8.3 is where people will be trying to debug
configuration files.

17 years agoFix the code that adds regclass constants to a plan's list of relation OIDs
Tom Lane [Tue, 17 Jun 2008 14:51:38 +0000 (14:51 +0000)]
Fix the code that adds regclass constants to a plan's list of relation OIDs
that it depends on for replan-forcing purposes.  We need to consider plain OID
constants too, because eval_const_expressions folds a RelabelType atop a Const
to just a Const.  This change could result in OID values that aren't really
for tables getting added to the dependency list, but the worst-case
consequence would be occasional useless replans.  Per report from Gabriele
Messineo.

17 years agoClean up a number of bogosities around pltcl's handling of the Tcl "result":
Tom Lane [Tue, 17 Jun 2008 00:52:49 +0000 (00:52 +0000)]
Clean up a number of bogosities around pltcl's handling of the Tcl "result":

1. Directly reading interp->result is deprecated in Tcl 8.0 and later;
you're supposed to use Tcl_GetStringResult.  This code finally broke with
Tcl 8.5, because Tcl_GetVar can now have side-effects on interp->result even
though it preserves the logical state of the result.  (There's arguably a
Tcl issue here, because Tcl_GetVar could invalidate the pointer result of a
just-preceding Tcl_GetStringResult, but I doubt the Tcl guys will see it as
a bug.)

2. We were being sloppy about the encoding of the result: some places would
push database-encoding data into the Tcl result, which should not happen,
and we were assuming that any error result coming back from Tcl was in the
database encoding, which is not a good assumption.

3. There were a lot of calls of Tcl_SetResult that uselessly specified
TCL_VOLATILE for constant strings.  This is only a minor performance issue,
but I fixed it in passing since I had to look at all the calls anyway.

#2 is a live bug regardless of which Tcl version you are interested in,
so back-patch even to branches that are unlikely to be used with Tcl 8.5.
I went back as far as 8.0, which is as far as the patch applied easily;
7.4 was using a different error processing scheme that has got its own
problems :-(

17 years agoImprove the various elog messages in tuptoaster.c to report which TOAST table
Tom Lane [Fri, 13 Jun 2008 02:59:52 +0000 (02:59 +0000)]
Improve the various elog messages in tuptoaster.c to report which TOAST table
the problem happened in.  These are all supposedly can't-happen cases, but
when they do happen it's useful to know where.

Back-patch to 8.3, but not further because the patch doesn't apply cleanly
further back.  Given the lack of response to my proposal of this, there
doesn't seem to be enough interest to justify much back-porting effort.

17 years agoFix bug in the WAL recovery code to finish an incomplete split.
Heikki Linnakangas [Wed, 11 Jun 2008 08:40:32 +0000 (08:40 +0000)]
Fix bug in the WAL recovery code to finish an incomplete split.
CacheInvalidateRelcache() crashes if called in WAL recovery, because the
invalidation infrastructure hasn't been initialized yet.

Back-patch to 8.2, where the bug was introduced.

17 years agoCreate a script to handle stamping release version numbers into files,
Tom Lane [Tue, 10 Jun 2008 18:08:55 +0000 (18:08 +0000)]
Create a script to handle stamping release version numbers into files,
replacing the tedious and error-prone manual process we've been using.

17 years agoFix unportable (and incorrect anyway) usage of LL constant suffix that
Tom Lane [Mon, 9 Jun 2008 19:58:46 +0000 (19:58 +0000)]
Fix unportable (and incorrect anyway) usage of LL constant suffix that
recently snuck into cash.c.  Per report from Edmundo Robles Lopez.

17 years agoFix datetime input functions to correctly detect integer overflow when
Tom Lane [Mon, 9 Jun 2008 19:34:09 +0000 (19:34 +0000)]
Fix datetime input functions to correctly detect integer overflow when
running on a 64-bit platform ... strtol() will happily return 64-bit
output in that case.  Per bug #4231 from Geoff Tolley.