]> granicus.if.org Git - postgresql/log
postgresql
17 years agoFix typo, noted by Stefan Kaltenbrunner.
Magnus Hagander [Mon, 21 Apr 2008 11:06:23 +0000 (11:06 +0000)]
Fix typo, noted by Stefan Kaltenbrunner.

17 years agoAdd link to major version release notes at the top of the minor
Magnus Hagander [Mon, 21 Apr 2008 09:45:20 +0000 (09:45 +0000)]
Add link to major version release notes at the top of the minor
version ones, to make it clear to users just browsing the notes
that there are a lot more changes available from whatever version
they are at than what's in the minor version release notes.

17 years agoFix a couple of places in execMain that erroneously assumed that SELECT FOR
Tom Lane [Mon, 21 Apr 2008 03:49:51 +0000 (03:49 +0000)]
Fix a couple of places in execMain that erroneously assumed that SELECT FOR
UPDATE/SHARE couldn't occur as a subquery in a query with a non-SELECT
top-level operation.  Symptoms included outright failure (as in report from
Mark Mielke) and silently neglecting to take the requested row locks.

Back-patch to 8.3, because the visible failure in the INSERT ... SELECT case
is a regression from 8.2.  I'm a bit hesitant to back-patch further given the
lack of field complaints.

17 years agoFix broken compare function for tsquery_ops. Per Tom's report.
Teodor Sigaev [Sun, 20 Apr 2008 09:29:48 +0000 (09:29 +0000)]
Fix broken compare function for tsquery_ops. Per Tom's report.

I never understood why initial authors GiST in pgsql choose so
stgrange signature for 'same' method:
bool *sameFn(Datum a, Datum b, bool* result)
instead of simple, logical
bool sameFn(Datum a, Datum b)
This change will break any existing GiST extension, so we still live with
it and will live.

17 years agoFix rmtree() so that it keeps going after failure to remove any individual
Tom Lane [Fri, 18 Apr 2008 17:05:53 +0000 (17:05 +0000)]
Fix rmtree() so that it keeps going after failure to remove any individual
file; the idea is that we should clean up as much as we can, even if there's
some problem removing one file.  Make the error messages a bit less misleading,
too.  In passing, const-ify function arguments.

17 years agoFix two race conditions between the pending unlink mechanism that was put in
Heikki Linnakangas [Fri, 18 Apr 2008 06:48:50 +0000 (06:48 +0000)]
Fix two race conditions between the pending unlink mechanism that was put in
place to prevent reusing relation OIDs before next checkpoint, and DROP
DATABASE. First, if a database was dropped, bgwriter would still try to unlink
the files that the rmtree() call by the DROP DATABASE command has already
deleted, or is just about to delete. Second, if a database is dropped, and
another database is created with the same OID, bgwriter would in the worst
case delete a relation in the new database that happened to get the same OID
as a dropped relation in the old database.

To fix these race conditions:
- make rmtree() ignore ENOENT errors. This fixes the 1st race condition.
- make ForgetDatabaseFsyncRequests forget unlink requests as well.
- force checkpoint on in dropdb on all platforms

Since ForgetDatabaseFsyncRequests() is asynchronous, the 2nd change isn't
enough on its own to fix the problem of dropping and creating a database with
same OID, but forcing a checkpoint on DROP DATABASE makes it sufficient.

Per Tom Lane's bug report and proposal. Backpatch to 8.3.

17 years agoFix a couple of oversights associated with the "physical tlist" optimization:
Tom Lane [Thu, 17 Apr 2008 21:22:23 +0000 (21:22 +0000)]
Fix a couple of oversights associated with the "physical tlist" optimization:
we had several code paths where a physical tlist could be used for the input
to a Sort node, which is a dumb idea because any unneeded table columns will
increase the volume of data the sort has to push around.

(Unfortunately the easy-looking fix of calling disuse_physical_tlist during
make_sort_xxx doesn't work because in most cases we're already committed to
the current input tlist --- it's been marked with sort column numbers, or
we've built grouping column numbers using it, etc.  The tlist has to be
selected properly at the calling level before we start constructing sort-col
information.  This is easy enough to do, we were just failing to take the
point into consideration.)

Back-patch to 8.3.  I believe the problem probably exists clear back to 7.4
when the physical tlist optimization was added, but I'm afraid to back-patch
further than 8.3 without a great deal more study than I want to put into it.
The code in this area has drifted a lot over time.  The real-world importance
of these code paths is uncertain anyway --- I think in many cases we'd
probably prefer hash-based methods.

17 years agoRepair two places where SIGTERM exit could leave shared memory state
Tom Lane [Wed, 16 Apr 2008 23:59:51 +0000 (23:59 +0000)]
Repair two places where SIGTERM exit could leave shared memory state
corrupted.  (Neither is very important if SIGTERM is used to shut down the
whole database cluster together, but there's a problem if someone tries to
SIGTERM individual backends.)  To do this, introduce new infrastructure
macros PG_ENSURE_ERROR_CLEANUP/PG_END_ENSURE_ERROR_CLEANUP that take care
of transiently pushing an on_shmem_exit cleanup hook.  Also use this method
for createdb cleanup --- that wasn't a shared-memory-corruption problem,
but SIGTERM abort of createdb could leave orphaned files lying around.

Backpatch as far as 8.2.  The shmem corruption cases don't exist in 8.1,
and the createdb usage doesn't seem important enough to risk backpatching
further.

17 years agoFix LOAD_CRIT_INDEX() macro to take out AccessShareLock on the system index
Tom Lane [Wed, 16 Apr 2008 18:23:12 +0000 (18:23 +0000)]
Fix LOAD_CRIT_INDEX() macro to take out AccessShareLock on the system index
it is trying to build a relcache entry for.  This is an oversight in my 8.2
patch that tried to ensure we always took a lock on a relation before trying
to build its relcache entry.  The implication is that if someone committed a
reindex of a critical system index at about the same time that some other
backend were starting up without a valid pg_internal.init file, the second one
might PANIC due to not seeing any valid version of the index's pg_class row.
Improbable case, but definitely not impossible.

17 years agoAvoid using unnecessary pgwin32_safestat in libpq.
Andrew Dunstan [Wed, 16 Apr 2008 14:21:23 +0000 (14:21 +0000)]
Avoid using unnecessary pgwin32_safestat in libpq.

17 years agoAdd multi-line flag to regex that needs it. Backpatch to 8.2. Fix from Andreas Zeugsw...
Andrew Dunstan [Tue, 15 Apr 2008 16:23:21 +0000 (16:23 +0000)]
Add multi-line flag to regex that needs it. Backpatch to 8.2. Fix from Andreas Zeugswetter

17 years agoA quick try at un-breaking the Cygwin build. Whether it needs the
Tom Lane [Fri, 11 Apr 2008 23:59:49 +0000 (23:59 +0000)]
A quick try at un-breaking the Cygwin build.  Whether it needs the
pgwin32_safestat remains to be determined, but in any case the current
code is not tolerable.

17 years agoFix several datatype input functions that were allowing unused bytes in their
Tom Lane [Fri, 11 Apr 2008 22:52:17 +0000 (22:52 +0000)]
Fix several datatype input functions that were allowing unused bytes in their
results to contain uninitialized, unpredictable values.  While this was okay
as far as the datatypes themselves were concerned, it's a problem for the
parser because occurrences of the "same" literal might not be recognized as
equal by datumIsEqual (and hence not by equal()).  It seems sufficient to fix
this in the input functions since the only critical use of equal() is in the
parser's comparisons of ORDER BY and DISTINCT expressions.
Per a trouble report from Marc Cousin.

Patch all the way back.  Interestingly, array_in did not have the bug before
8.2, which may explain why the issue went unnoticed for so long.

17 years agoCreate wrapper pgwin32_safestat() and redefine stat() to it
Magnus Hagander [Thu, 10 Apr 2008 16:59:10 +0000 (16:59 +0000)]
Create wrapper pgwin32_safestat() and redefine stat() to it
on win32, because the stat() function in the runtime cannot
be trusted to always update the st_size field.

Per report and research by Sergey Zubkovsky.

17 years agoFixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract.
Michael Meskes [Thu, 10 Apr 2008 10:46:22 +0000 (10:46 +0000)]
Fixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract.

17 years agoFix tsvector_update_trigger() to be domain-friendly: it needs to allow all
Tom Lane [Tue, 8 Apr 2008 18:20:34 +0000 (18:20 +0000)]
Fix tsvector_update_trigger() to be domain-friendly: it needs to allow all
the columns it works with to be domains over the expected type, not just
exactly the expected type.  In passing, fix ts_stat() the same way.
Per report from Markus Wollny.

17 years agoDefend against JOINs having more than 32K columns altogether. We cannot
Tom Lane [Sat, 5 Apr 2008 01:58:28 +0000 (01:58 +0000)]
Defend against JOINs having more than 32K columns altogether.  We cannot
currently support this because we must be able to build Vars referencing
join columns, and varattno is only 16 bits wide.  Perhaps this should be
improved in future, but considering that it never came up before, I'm not
sure the problem is worth much effort.  Per bug #4070 from Marcello
Ceschia.

The problem seems largely academic in 8.0 and 7.4, because they have
(different) O(N^2) performance issues with such wide joins, but
back-patch all the way anyway.

17 years agoTeach ANALYZE to distinguish dead and in-doubt tuples, which it formerly
Tom Lane [Thu, 3 Apr 2008 16:27:32 +0000 (16:27 +0000)]
Teach ANALYZE to distinguish dead and in-doubt tuples, which it formerly
classed all as "dead"; also get it to count DEAD item pointers as dead rows,
instead of ignoring them as before.  Also improve matters so that tuples
previously inserted or deleted by our own transaction are handled nicely:
the stats collector's live-tuple and dead-tuple counts will end up correct
after our transaction ends, regardless of whether we end in commit or abort.

While there's more work that could be done to improve the counting of in-doubt
tuples in both VACUUM and ANALYZE, this commit is enough to alleviate some
known bad behaviors in 8.3; and the other stuff that's been discussed seems
like research projects anyway.

Pavan Deolasee and Tom Lane

17 years agoRemove -C from rsync call, because it omits directories named "core".
Peter Eisentraut [Thu, 3 Apr 2008 09:51:53 +0000 (09:51 +0000)]
Remove -C from rsync call, because it omits directories named "core".

17 years agoRevert my bad decision of about a year ago to make PortalDefineQuery
Tom Lane [Wed, 2 Apr 2008 18:32:00 +0000 (18:32 +0000)]
Revert my bad decision of about a year ago to make PortalDefineQuery
responsible for copying the query string into the new Portal.  Such copying
is unnecessary in the common code path through exec_simple_query, and in
this case it can be enormously expensive because the string might contain
a large number of individual commands; we were copying the entire, long
string for each command, resulting in O(N^2) behavior for N commands.
(This is the cause of bug #4079.)  A second problem with it is that
PortalDefineQuery really can't risk error, because if it elog's before
having set up the Portal, we will leak the plancache refcount that the
caller is trying to hand off to the portal.  So go back to the design in
which the caller is responsible for making sure everything is copied into
the portal if necessary.

17 years agoFix an oversight I made in a cleanup patch over a year ago:
Tom Lane [Tue, 1 Apr 2008 00:48:44 +0000 (00:48 +0000)]
Fix an oversight I made in a cleanup patch over a year ago:
eval_const_expressions needs to be passed the PlannerInfo ("root") structure,
because in some cases we want it to substitute values for Param nodes.
(So "constant" is not so constant as all that ...)  This mistake partially
disabled optimization of unnamed extended-Query statements in 8.3: in
particular the LIKE-to-indexscan optimization would never be applied if the
LIKE pattern was passed as a parameter, and constraint exclusion depending
on a parameter value didn't work either.

17 years agoApply my original fix for Taiki Yamaguchi's bug report about DISTINCT MAX().
Tom Lane [Mon, 31 Mar 2008 16:59:33 +0000 (16:59 +0000)]
Apply my original fix for Taiki Yamaguchi's bug report about DISTINCT MAX().
Add some regression tests for plausible failures in this area.

17 years agoFix a number of places that were making file-type tests infelicitously.
Tom Lane [Mon, 31 Mar 2008 01:32:01 +0000 (01:32 +0000)]
Fix a number of places that were making file-type tests infelicitously.
The places that did, eg,
(statbuf.st_mode & S_IFMT) == S_IFDIR
were correct, but there is no good reason not to use S_ISDIR() instead,
especially when that's what the other 90% of our code does.  The places
that did, eg,
(statbuf.st_mode & S_IFDIR)
were flat out *wrong* and would fail in various platform-specific ways,
eg a symlink could be mistaken for a regular file on most Unixen.

The actual impact of this is probably small, since the problem cases
seem to always involve symlinks or sockets, which are unlikely to be
found in the directories that PG code might be scanning.  But it's
clearly trouble waiting to happen, so patch all the way back anyway.
(There seem to be no occurrences of the mistake in 7.4.)

17 years agoRevert my erroneous fix for Taiki Yamaguchi's DISTINCT MAX() bug.
Tom Lane [Sat, 29 Mar 2008 00:15:37 +0000 (00:15 +0000)]
Revert my erroneous fix for Taiki Yamaguchi's DISTINCT MAX() bug.
Whatever we do about that, this isn't the path to the solution.

17 years agoWhen we have successfully optimized a MIN or MAX aggregate into an indexscan,
Tom Lane [Thu, 27 Mar 2008 19:06:23 +0000 (19:06 +0000)]
When we have successfully optimized a MIN or MAX aggregate into an indexscan,
the query result must be exactly one row (since we don't do this when there's
any GROUP BY).  Therefore any ORDER BY or DISTINCT attached to the query is
useless and can be dropped.  Aside from saving useless cycles, this protects
us against problems with matching the hacked-up tlist entries to sort clauses,
as seen in a bug report from Taiki Yamaguchi.  We might need to work harder
if we ever try to optimize grouped queries with this approach, but this
solution will do for now.

17 years agoInclude \password in the psql help.
Magnus Hagander [Wed, 26 Mar 2008 15:52:36 +0000 (15:52 +0000)]
Include \password in the psql help.

While at it, change the order of the documented options to be
alphabetically again.

17 years agoFix core dump in contrib/xml2's xpath_table() when the input query returns
Tom Lane [Wed, 26 Mar 2008 01:19:11 +0000 (01:19 +0000)]
Fix core dump in contrib/xml2's xpath_table() when the input query returns
a NULL value.  Per bug #4058.

17 years agoadded ECPGget_PGconn to exports.txt
Michael Meskes [Tue, 25 Mar 2008 12:45:33 +0000 (12:45 +0000)]
added ECPGget_PGconn to exports.txt

17 years agoWhen a relation has been proven empty by constraint exclusion, propagate that
Tom Lane [Mon, 24 Mar 2008 21:53:12 +0000 (21:53 +0000)]
When a relation has been proven empty by constraint exclusion, propagate that
knowledge up through any joins it participates in.  We were doing that already
in some special cases but not in the general case.  Also, defend against zero
row estimates for the input relations in cost_mergejoin --- this fix may have
eliminated the only scenario in which that can happen, but be safe.  Per
report from Alex Solovey.

17 years agoFix various infelicities that have snuck into usage of errdetail() and
Tom Lane [Mon, 24 Mar 2008 19:12:58 +0000 (19:12 +0000)]
Fix various infelicities that have snuck into usage of errdetail() and
friends.  Avoid double translation of some messages, ensure other messages
are exposed for translation (and make them follow the style guidelines),
avoid unsafe passing of an unpredictable message text as a format string.

17 years agoCorrected version number.
Michael Meskes [Fri, 21 Mar 2008 16:10:10 +0000 (16:10 +0000)]
Corrected version number.

17 years agoAdded ECPGget_PGconn() function to ecpglib, courtesy of Mike Aubury.
Michael Meskes [Thu, 20 Mar 2008 16:30:14 +0000 (16:30 +0000)]
Added ECPGget_PGconn() function to ecpglib, courtesy of Mike Aubury.
Bumped library version to 6.1.

17 years agoChanged statement escaping to not escape continuation line markers.
Michael Meskes [Thu, 20 Mar 2008 16:04:52 +0000 (16:04 +0000)]
Changed statement escaping to not escape continuation line markers.
Bumped precompiler patchlevel.

17 years agoAdd the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
Heikki Linnakangas [Thu, 20 Mar 2008 10:35:45 +0000 (10:35 +0000)]
Add the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
ISO_8859-5 <-> MULE_INTERNAL conversion tables.

This was discovered when trying to convert a string containing those characters
from ISO_8859-5 to Windows-1251, because we use MULE_INTERNAL/KOI8R as an
intermediate encoding between those two.

While the missing "Yo" was just an omission in the conversion tables, there are
a few other characters like the "Numero" sign ("No" as a single character) that
exists in all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
not in KOI8R. Added comments about that.

Patch by Sergey Burladyan. Back-patch to 7.4.

17 years agoFix regexp substring matching (substring(string from pattern)) for the corner
Tom Lane [Wed, 19 Mar 2008 02:40:43 +0000 (02:40 +0000)]
Fix regexp substring matching (substring(string from pattern)) for the corner
case where there is a match to the pattern overall but the user has specified
a parenthesized subexpression and that subexpression hasn't got a match.
An example is substring('foo' from 'foo(bar)?').  This should return NULL,
since (bar) isn't matched, but it was mistakenly returning the whole-pattern
match instead (ie, 'foo').  Per bug #4044 from Rui Martins.

This has been broken since the beginning; patch in all supported versions.
The old behavior was sufficiently inconsistent that it's impossible to believe
anyone is depending on it.

17 years agocvsweb lives on anoncvs.postgresql.org these days.
Magnus Hagander [Tue, 18 Mar 2008 16:05:09 +0000 (16:05 +0000)]
cvsweb lives on anoncvs.postgresql.org these days.

17 years agoWiki page about cvs now lives in the main wiki, the one
Magnus Hagander [Tue, 18 Mar 2008 16:02:29 +0000 (16:02 +0000)]
Wiki page about cvs now lives in the main wiki, the one
on developer.postgresql.org is going away.

17 years agoFix inappropriately-timed memory context switch in autovacuum_do_vac_analyze. REL8_3_1
Tom Lane [Fri, 14 Mar 2008 23:49:33 +0000 (23:49 +0000)]
Fix inappropriately-timed memory context switch in autovacuum_do_vac_analyze.
This accidentally failed to fail before 8.3, because the context we were
switching back to was long-lived anyway; but it sure looks risky as can be
now.  Well spotted by Pavan Deolasee.

17 years agoFix duplicate word, per Guillaume Lelarge.
Alvaro Herrera [Fri, 14 Mar 2008 17:28:24 +0000 (17:28 +0000)]
Fix duplicate word, per Guillaume Lelarge.

17 years agoFix vacuum so that autovacuum is really not cancelled when doing an emergency
Alvaro Herrera [Fri, 14 Mar 2008 17:26:01 +0000 (17:26 +0000)]
Fix vacuum so that autovacuum is really not cancelled when doing an emergency
job (i.e. to prevent Xid wraparound problems.)  Bug reported by ITAGAKI
Takahiro in 20080314103837.63D3.52131E4D@oss.ntt.co.jp, though I didn't use his
patch.

17 years agoTranslation updates
Peter Eisentraut [Fri, 14 Mar 2008 04:46:30 +0000 (04:46 +0000)]
Translation updates

17 years agoupdate configure for 8.3.1 prior to tag
Marc G. Fournier [Fri, 14 Mar 2008 03:23:22 +0000 (03:23 +0000)]
update configure for 8.3.1 prior to tag

17 years agoStamp version 8.3.1, except for configure.in/configure.
Tom Lane [Thu, 13 Mar 2008 23:57:34 +0000 (23:57 +0000)]
Stamp version 8.3.1, except for configure.in/configure.

17 years agoUpdate release notes for 8.3.1 and 8.2.7 releases.
Tom Lane [Thu, 13 Mar 2008 23:47:59 +0000 (23:47 +0000)]
Update release notes for 8.3.1 and 8.2.7 releases.

17 years agoUpdate to tzdata 2008a distribution (Chilean DST law change).
Tom Lane [Thu, 13 Mar 2008 19:21:49 +0000 (19:21 +0000)]
Update to tzdata 2008a distribution (Chilean DST law change).

17 years agoFix varstr_cmp's special case for UTF8 encoding on Windows so that strings
Tom Lane [Thu, 13 Mar 2008 18:32:02 +0000 (18:32 +0000)]
Fix varstr_cmp's special case for UTF8 encoding on Windows so that strings
that are reported as "equal" by wcscoll() are checked to see if they really
are bitwise equal, and are sorted per strcmp() if not.  We made this happen
a couple of years ago in the regular code path, but it unaccountably got
left out of the Windows/UTF8 case (probably brain fade on my part at the
time).  As in the prior set of changes, affected users may need to reindex
indexes on textual columns.

Backpatch as far as 8.2, which is the oldest release we are still supporting
on Windows.

17 years agoFix heap_page_prune's problem with failing to send cache invalidation
Tom Lane [Thu, 13 Mar 2008 18:00:39 +0000 (18:00 +0000)]
Fix heap_page_prune's problem with failing to send cache invalidation
messages if the calling transaction aborts later on.  Collapsing out line
pointer redirects is a done deal as soon as we complete the page update,
so syscache *must* be notified even if the VACUUM FULL as a whole doesn't
complete.  To fix, add some functionality to inval.c to allow the pending
inval messages to be sent immediately while heap_page_prune is still
running.  The implementation is a bit chintzy: it will only work in the
context of VACUUM FULL.  But that's all we need now, and it can always be
extended later if needed.  Per my trouble report of a week ago.

17 years agoFix pg_plan_queries() to restore the previous setting of ActiveSnapshot
Tom Lane [Wed, 12 Mar 2008 23:58:35 +0000 (23:58 +0000)]
Fix pg_plan_queries() to restore the previous setting of ActiveSnapshot
(probably NULL) before exiting.  Up to now it's just left the variable as it
set it, which means that after we're done processing the current client
message, ActiveSnapshot is probably pointing at garbage (because this function
is typically run in MessageContext which will get reset).  There doesn't seem
to have been any code path in which that mattered before 8.3, but now the
plancache module might try to use the stale value if the next client message
is a Bind for a prepared statement that is in need of replanning.  Per report
from Alex Hunsaker.

17 years agoFix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
Tom Lane [Wed, 12 Mar 2008 20:11:54 +0000 (20:11 +0000)]
Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
pg_listener modifications commanded by LISTEN and UNLISTEN until the end
of the current transaction.  This allows us to hold the ExclusiveLock on
pg_listener until after commit, with no greater risk of deadlock than there
was before.  Aside from fixing the race condition, this gets rid of a
truly ugly kludge that was there before, namely having to ignore
HeapTupleBeingUpdated failures during NOTIFY.  There is a small potential
incompatibility, which is that if a transaction issues LISTEN or UNLISTEN
and then looks into pg_listener before committing, it won't see any resulting
row insertion or deletion, where before it would have.  It seems unlikely
that anyone would be depending on that, though.

This patch also disallows LISTEN and UNLISTEN inside a prepared transaction.
That case had some pretty undesirable properties already, such as possibly
allowing pg_listener entries to be made for PIDs no longer present, so
disallowing it seems like a better idea than trying to maintain the behavior.

17 years agoAdd to documentation:
Bruce Momjian [Tue, 11 Mar 2008 16:59:09 +0000 (16:59 +0000)]
Add to documentation:

+         Setting <varname>statement_timeout</> in
+         <filename>postgresql.conf</> is not recommended because it
+         affects all sessions.

Backpatch to 8.3.X.

17 years agoBack out doc addition that statement_timeout affects autovacuum.
Bruce Momjian [Tue, 11 Mar 2008 15:49:52 +0000 (15:49 +0000)]
Back out doc addition that statement_timeout affects autovacuum.

17 years agoDocument that statement_timeout is not recommended in postgresql.conf
Bruce Momjian [Tue, 11 Mar 2008 15:39:33 +0000 (15:39 +0000)]
Document that statement_timeout is not recommended in postgresql.conf
because it affects all sessions, including autovacuum.

17 years agoUse -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.
Tom Lane [Mon, 10 Mar 2008 21:50:23 +0000 (21:50 +0000)]
Use -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.
This prevents compiler optimizations that assume overflow won't occur, which
breaks numerous overflow tests that we need to have working.  It is known
that gcc 4.3 causes problems and possible that 4.1 does.  Per my proposal
of some time ago and a recent report from Kris Jurka.

Backpatch as far as 8.0, which is as far as the patch conveniently goes.
7.x was pretty short of overflow tests anyway, so it may not matter there,
even assuming that anyone cares whether 7.x builds on recent gcc.

17 years agoRevert changes of CompareTSQ: it affects existing btree indexes.
Teodor Sigaev [Sun, 9 Mar 2008 10:42:48 +0000 (10:42 +0000)]
Revert changes of CompareTSQ: it affects existing btree indexes.

17 years agoRefactor heap_page_prune so that instead of changing item states on-the-fly,
Tom Lane [Sat, 8 Mar 2008 21:58:07 +0000 (21:58 +0000)]
Refactor heap_page_prune so that instead of changing item states on-the-fly,
it accumulates the set of changes to be made and then applies them.  It had
to accumulate the set of changes anyway to prepare a WAL record for the
pruning action, so this isn't an enormous change; the only new complexity is
to not doubly mark tuples that are visited twice in the scan.  The main
advantage is that we can substantially reduce the scope of the critical
section in which the changes are applied, thus avoiding PANIC in foreseeable
cases like running out of memory in inval.c.  A nice secondary advantage is
that it is now far clearer that WAL replay will actually do the same thing
that the original pruning did.

This commit doesn't do anything about the open problem that
CacheInvalidateHeapTuple doesn't have the right semantics for a CTID change
caused by collapsing out a redirect pointer.  But whatever we do about that,
it'll be a good idea to not do it inside a critical section.

17 years agoChange hashscan.c to keep its list of active hash index scans in
Tom Lane [Fri, 7 Mar 2008 15:59:09 +0000 (15:59 +0000)]
Change hashscan.c to keep its list of active hash index scans in
TopMemoryContext, rather than scattered through executor per-query contexts.
This poses no danger of memory leak since the ResourceOwner mechanism
guarantees release of no-longer-needed items.  It is needed because the
per-query context might already be released by the time we try to clean up
the hash scan list.  Report by ykhuang, diagnosis by Heikki.

Back-patch to 8.0, where the ResourceOwner-based cleanup was introduced.
The given test case does not fail before 8.2, probably because we rearranged
transaction abort processing somehow; but this coding is undoubtedly risky
so I'll patch 8.0 and 8.1 anyway.

17 years agoFix memory arrangement of tsquery after removing stop words. It causes
Teodor Sigaev [Fri, 7 Mar 2008 15:29:27 +0000 (15:29 +0000)]
Fix memory arrangement  of tsquery after removing stop words. It causes
a unused memory holes in tsquery.

Per report by Richard Huxton <dev@archonet.com>.

It was working well because in fact tsquery->size is not used for any
kind of operation except comparing tsqueries. To prevent requirement
of renew all stored tsquery optimization in CompareTSQ is removed.

17 years agoClearify PITR doc wording.
Bruce Momjian [Fri, 7 Mar 2008 01:46:50 +0000 (01:46 +0000)]
Clearify PITR doc wording.

17 years agoDocument that enabling asserts can _significantly_ slow down the server.
Bruce Momjian [Thu, 6 Mar 2008 21:37:40 +0000 (21:37 +0000)]
Document that enabling asserts can _significantly_ slow down the server.
Back patch to 8.3.X.

17 years agoMove client encoding libpq function docs into libpq doc section, and
Bruce Momjian [Thu, 6 Mar 2008 15:38:02 +0000 (15:38 +0000)]
Move client encoding libpq function docs into libpq doc section, and
just reference them from the localization doc section.

Backpatch to 8.3.X.

17 years agoAdd support for dlopen on recent NetBSD/MIPS, per Rémi Zara.
Alvaro Herrera [Wed, 5 Mar 2008 21:20:47 +0000 (21:20 +0000)]
Add support for dlopen on recent NetBSD/MIPS, per Rémi Zara.

17 years agoUpdate libpqxx URL in top-level README, per Gurjeet Singh.
Bruce Momjian [Wed, 5 Mar 2008 17:04:42 +0000 (17:04 +0000)]
Update libpqxx URL in top-level README, per Gurjeet Singh.

17 years agoIn PrepareToInvalidateCacheTuple, don't force initialization of catalog
Tom Lane [Wed, 5 Mar 2008 17:01:33 +0000 (17:01 +0000)]
In PrepareToInvalidateCacheTuple, don't force initialization of catalog
caches that we don't actually need to touch.  This saves some trivial
number of cycles and avoids certain cases of deadlock when doing concurrent
VACUUM FULL on system catalogs.  Per report from Gavin Roy.

Backpatch to 8.2.  In earlier versions, CatalogCacheInitializeCache didn't
lock the relation so there's no deadlock risk (though that certainly had
plenty of risks of its own).

17 years agoDocument that increasing the number of checkpoints segments or
Bruce Momjian [Wed, 5 Mar 2008 17:00:40 +0000 (17:00 +0000)]
Document that increasing the number of checkpoints segments or
checkpoint timeout can incrase the time needed for crash recovery, per
suggestion from Simon.

17 years agoInclude -lgss in libpq link, if available. Bjorn Munch
Tom Lane [Wed, 5 Mar 2008 05:39:17 +0000 (05:39 +0000)]
Include -lgss in libpq link, if available.  Bjorn Munch

17 years agoFix PREPARE TRANSACTION to reject the case where the transaction has dropped a
Tom Lane [Tue, 4 Mar 2008 19:54:13 +0000 (19:54 +0000)]
Fix PREPARE TRANSACTION to reject the case where the transaction has dropped a
temporary table; we can't support that because there's no way to clean up the
source backend's internal state if the eventual COMMIT PREPARED is done by
another backend.  This was checked correctly in 8.1 but I broke it in 8.2 :-(.
Patch by Heikki Linnakangas, original trouble report by John Smith.

17 years agoUse windows DACL fix for pg_regress as well.
Magnus Hagander [Tue, 4 Mar 2008 15:38:33 +0000 (15:38 +0000)]
Use windows DACL fix for pg_regress as well.

Dave Page

17 years agoShow example of ts_headline() using a configuration name.
Bruce Momjian [Tue, 4 Mar 2008 03:17:26 +0000 (03:17 +0000)]
Show example of ts_headline() using a configuration name.

17 years agoRemove "reliably" from chr(0) doc mention.
Bruce Momjian [Mon, 3 Mar 2008 18:09:09 +0000 (18:09 +0000)]
Remove "reliably" from chr(0) doc mention.

17 years agoDocument that chr(0) is not supported, and why.
Bruce Momjian [Mon, 3 Mar 2008 17:11:23 +0000 (17:11 +0000)]
Document that chr(0) is not supported, and why.

17 years agoFixed bug that caused arrays of varchar to be output with incomplete name.
Michael Meskes [Sun, 2 Mar 2008 10:57:21 +0000 (10:57 +0000)]
Fixed bug that caused arrays of varchar to be output with incomplete name.

17 years agoVenezuela Time now means UTC-4:30, not UTC-4:00. Adjust our treatment
Tom Lane [Sun, 2 Mar 2008 00:10:28 +0000 (00:10 +0000)]
Venezuela Time now means UTC-4:30, not UTC-4:00.  Adjust our treatment
of "VET" accordingly.  Per bug #3997 from Aaron Mizrachi.

17 years agoFix another place that was assuming that a local variable declared as
Tom Lane [Sat, 1 Mar 2008 19:26:28 +0000 (19:26 +0000)]
Fix another place that was assuming that a local variable declared as
"struct varlena" would be at least word-aligned.  Per buildfarm results
from gypsy_moth.  I did a little bit of trawling for other instances of
this coding pattern, and didn't find any; but if we turn up any more
of them I think we'd better revert the "char [4]" patch and find another
way of making tuptoaster.c alignment-safe.

17 years agoFix unportable usages of tolower(). On signed-char machines, it is necessary
Tom Lane [Sat, 1 Mar 2008 03:26:44 +0000 (03:26 +0000)]
Fix unportable usages of tolower().  On signed-char machines, it is necessary
to explicitly cast the output back to char before comparing it to a char
value, else we get the wrong result for high-bit-set characters.  Found by
Rolf Jentsch.  Also, fix several places where <ctype.h> functions were being
called without casting the argument to unsigned char; this is likewise
unportable, but we keep making that mistake :-(.  These found by buildfarm
member salamander, which I will desperately miss if it ever goes belly-up.

17 years agoDisable the undocumented xmlvalidate() function, which was unintentionally
Tom Lane [Sat, 1 Mar 2008 02:46:55 +0000 (02:46 +0000)]
Disable the undocumented xmlvalidate() function, which was unintentionally
left in the code though it was not meant to be provided.  It represents a
security hole because unprivileged users could use it to look at (at least the
first line of) any file readable by the backend.  Fortunately, this is only
possible if the backend was built with XML support, so the damage is at least
mitigated; and 8.3 probably hasn't propagated into any security-critical uses
yet anyway.  Per report from Sergey Burladyan.

17 years agoDon't call AddUserToDacl on Cygwin
Andrew Dunstan [Fri, 29 Feb 2008 23:31:42 +0000 (23:31 +0000)]
Don't call AddUserToDacl on Cygwin

17 years agoReducing the assumed alignment of struct varlena means that the compiler
Tom Lane [Fri, 29 Feb 2008 17:47:47 +0000 (17:47 +0000)]
Reducing the assumed alignment of struct varlena means that the compiler
is also licensed to put a local variable declared that way at an unaligned
address.  Which will not work if the variable is then manipulated with
SET_VARSIZE or other macros that assume alignment.  So the previous patch
is not an unalloyed good, but on balance I think it's still a win, since
we have very few places that do that sort of thing.  Fix the one place in
tuptoaster.c that does it.  Per buildfarm results from gypsy_moth
(I'm a bit surprised that only one machine showed a failure).

17 years agoFix handling of restricted processes for Windows Vista (mainly),
Magnus Hagander [Fri, 29 Feb 2008 15:31:41 +0000 (15:31 +0000)]
Fix handling of restricted processes for Windows Vista (mainly),
by explicitly adding back the user to the DACL of the new process.
This fixes the failure case when executing as the Administrator
user, which had no permissions left at all after we dropped the
Administrators group.

Dave Page with some modifications from me

17 years agoFix several memory leaks when rescanning SRFs. Arrange for an SRF's
Neil Conway [Fri, 29 Feb 2008 02:49:43 +0000 (02:49 +0000)]
Fix several memory leaks when rescanning SRFs. Arrange for an SRF's
"multi_call_ctx" to be a distinct sub-context of the EState's per-query
context, and delete the multi_call_ctx as soon as the SRF finishes
execution. This avoids leaking SRF memory until the end of the current
query, which is particularly egregious when the SRF is scanned
multiple times. This change also fixes a leak of the fields of the
AttInMetadata struct in shutdown_MultiFuncCall().

Also fix a leak of the SRF result TupleDesc when rescanning a
FunctionScan node. The TupleDesc is allocated in the per-query context
for every call to ExecMakeTableFunctionResult(), so we should free it
after calling that function. Since the SRF might choose to return
a non-expendable TupleDesc, we only free the TupleDesc if it is
not being reference-counted.

Backpatch to 8.3 and 8.2 stable branches.

17 years agoSupport for building contrib/uuid-ossp with MSVC.
Magnus Hagander [Thu, 28 Feb 2008 12:18:03 +0000 (12:18 +0000)]
Support for building contrib/uuid-ossp with MSVC.

Original patch from Hiroshi Saito, modified by me.

17 years agoIf RelationBuildDesc() fails to open a critical system index, PANIC with
Tom Lane [Wed, 27 Feb 2008 17:44:27 +0000 (17:44 +0000)]
If RelationBuildDesc() fails to open a critical system index, PANIC with
a relevant error message instead of just dumping core.  Odd that nobody
reported this before Darren Reed.

17 years agoFix uninstall target.
Peter Eisentraut [Tue, 26 Feb 2008 13:49:14 +0000 (13:49 +0000)]
Fix uninstall target.

17 years agoFix encode(...bytea..., 'escape') so that it converts all high-bit-set byte
Tom Lane [Tue, 26 Feb 2008 02:54:14 +0000 (02:54 +0000)]
Fix encode(...bytea..., 'escape') so that it converts all high-bit-set byte
values into \nnn octal escape sequences.  When the database encoding is
multibyte this is *necessary* to avoid generating invalidly encoded text.
Even in a single-byte encoding, the old behavior seems very hazardous ---
consider for example what happens if the text is transferred to another
database with a different encoding.  Decoding would then yield some other
bytea value than what was encoded, which is surely undesirable.  Per gripe
from Hernan Gonzalez.

Backpatch to 8.3, but not further.  This is a bit of a judgment call, but I
make it on these grounds: pre-8.3 we don't really have much encoding safety
anyway because of the convert() function family, and we would also have much
higher risk of breaking existing apps that may not be expecting this behavior.
8.3 is still new enough that we can probably get away with making this change
in the function's behavior.

17 years agoFix datetime input to behave correctly for Feb 29 in years BC.
Tom Lane [Mon, 25 Feb 2008 23:21:08 +0000 (23:21 +0000)]
Fix datetime input to behave correctly for Feb 29 in years BC.

Formerly, DecodeDate attempted to verify the day-of-the-month exactly, but
it was under the misapprehension that it would know whether we were looking
at a BC year or not.  In reality this check can't be made until the calling
function (eg DecodeDateTime) has processed all the fields.  So, split the
BC adjustment and validity checks out into a new function ValidateDate that
is called only after processing all the fields.  In passing, this patch
makes DecodeTimeOnly work for BC inputs, which it never did before.

(The historical veracity of all this is nonexistent, of course, but if
we're going to say we support proleptic Gregorian calendar then we should
do it correctly.  In any case the unpatched code is broken because it could
emit dates that it would then reject on re-inputting.)

Per report from Bernd Helmle.  Back-patch as far as 8.0; in 7.x we were
not using our own calendar support and so this seems a bit too risky
to put into 7.4.

17 years agoUse our own getopt() and getopt_long() on Solaris, because that platform's
Tom Lane [Sun, 24 Feb 2008 05:22:03 +0000 (05:22 +0000)]
Use our own getopt() and getopt_long() on Solaris, because that platform's
versions don't handle long options the way we want.  Per Zdenek Kotala.

17 years agoAvoid trying to print a NULL char pointer in --describe-config. On some
Tom Lane [Sat, 23 Feb 2008 19:23:37 +0000 (19:23 +0000)]
Avoid trying to print a NULL char pointer in --describe-config.  On some
platforms this works, but on some it crashes.  Zdenek Kotala

17 years agoChange the declaration of struct varlena so that the length word is
Tom Lane [Sat, 23 Feb 2008 19:11:55 +0000 (19:11 +0000)]
Change the declaration of struct varlena so that the length word is
represented as "char ...[4]" not "int32".  Since the length word is never
supposed to be accessed via this struct member anyway, this won't break
any existing code that is following the rules.  The advantage is that C
compilers will no longer assume that a pointer to struct varlena is
word-aligned, which prevents incorrect optimizations in TOAST-pointer
access and perhaps other places.  gcc doesn't seem to do this (at least
not at -O2), but the problem is demonstrable on some other compilers.

I changed struct inet as well, but didn't bother to touch a lot of other
struct definitions in which it wouldn't make any difference because there
were other fields forcing int alignment anyway.  Hopefully none of those
struct definitions are used for accessing unaligned Datums.

17 years agoFix mistakes in pg_ctl's code for "start -w" that tries to cope with
Tom Lane [Wed, 20 Feb 2008 22:18:20 +0000 (22:18 +0000)]
Fix mistakes in pg_ctl's code for "start -w" that tries to cope with
non-default settings for the postmaster's port number.  The code to parse
command line options and postgresql.conf entries wasn't quite right about
whitespace or quotes, and it was coded in a not-very-readable way too.
Per bug #3969 from Itagaki Takahiro, though this is more extensive than his
proposed patch (which fixed only the whitespace problem).
This code has been broken since it was put in in 8.0, so patch all the way
back.

17 years agoPut a CHECK_FOR_INTERRUPTS call into the loops that try to find a unique new
Tom Lane [Wed, 20 Feb 2008 17:44:14 +0000 (17:44 +0000)]
Put a CHECK_FOR_INTERRUPTS call into the loops that try to find a unique new
OID or new relfilenode.  If the existing OIDs are sufficiently densely
populated, this could take a long time (perhaps even be an infinite loop),
so it seems wise to allow the system to respond to a cancel interrupt here.
Per a gripe from Jacky Leng.

Backpatch as far as 8.1.  Older versions just fail on OID collision,
instead of looping.

17 years agoChange error message to be able to differentiate the two cases. Per suggestion
Alvaro Herrera [Wed, 20 Feb 2008 16:48:12 +0000 (16:48 +0000)]
Change error message to be able to differentiate the two cases.  Per suggestion
from Jaime Casanova.

17 years agoRemove unnecessary opening of other relation in RI_FKey_keyequal_upd_pk
Tom Lane [Mon, 18 Feb 2008 23:00:38 +0000 (23:00 +0000)]
Remove unnecessary opening of other relation in RI_FKey_keyequal_upd_pk
and RI_FKey_keyequal_upd_fk, as well as no-longer-needed calls of
ri_BuildQueryKeyFull.  Aside from saving a few cycles, this avoids needless
deadlock risks when an update is not changing the columns that participate
in an RI constraint.  Per a gripe from Alexey Nalbat.

Back-patch to 8.3.  Earlier releases did have a need to open the other
relation due to the way in which they retrieved information about the RI
constraint, so this problem unfortunately can't easily be improved pre-8.3.

Tom Lane and Stephan Szabo

17 years agoObserve errors in makefile
Peter Eisentraut [Mon, 18 Feb 2008 16:04:20 +0000 (16:04 +0000)]
Observe errors in makefile

17 years agoChanged INFORMIX mode symbol definition yet again because the old way didn't work...
Michael Meskes [Sun, 17 Feb 2008 18:42:23 +0000 (18:42 +0000)]
Changed INFORMIX mode symbol definition yet again because the old way didn't work on NetBSD.

17 years agoUpdated expected result for regression test.
Michael Meskes [Fri, 15 Feb 2008 18:51:57 +0000 (18:51 +0000)]
Updated expected result for regression test.

17 years agoFixed conflicting commit.
Michael Meskes [Fri, 15 Feb 2008 16:28:47 +0000 (16:28 +0000)]
Fixed conflicting commit.

17 years agoChanged the way symbols are defined in C in INFORMIX mode.
Michael Meskes [Fri, 15 Feb 2008 12:11:02 +0000 (12:11 +0000)]
Changed the way symbols are defined in C in INFORMIX mode.
Added SQLSTATE macro closing bug #3961.
EXECUTE can return NOT FOUND so it should be checked here too.

17 years agoCorrect XML markup typo, <book> -> </book>
Bruce Momjian [Wed, 13 Feb 2008 22:47:09 +0000 (22:47 +0000)]
Correct XML markup typo, <book> -> </book>

 XMLPARSE (DOCUMENT '<?xml
 version="1.0"?><book><title>Manual</title><chapter>...</chapter></book>')

Backpatch to 8.3.X.

17 years agoFix SPI_cursor_open() and SPI_is_cursor_plan() to push the SPI stack before
Tom Lane [Tue, 12 Feb 2008 04:09:44 +0000 (04:09 +0000)]
Fix SPI_cursor_open() and SPI_is_cursor_plan() to push the SPI stack before
doing anything interesting, such as calling RevalidateCachedPlan().  The
necessity of this is demonstrated by an example from Willem Buitendyk:
during a replan, the planner might try to evaluate SPI-using functions,
and so we'd better be in a clean SPI context.

A small downside of this fix is that these two functions will now fail
outright if called when not inside a SPI-using procedure (ie, a
SPI_connect/SPI_finish pair).  The documentation never promised or suggested
that that would work, though; and they are normally used in concert with
other functions, mainly SPI_prepare, that always have failed in such a case.
So the odds of breaking something seem pretty low.

In passing, make SPI_is_cursor_plan's error handling convention clearer,
and fix documentation's erroneous claim that SPI_cursor_open would
return NULL on error.

Before 8.3 these functions could not invoke replanning, so there is probably
no need for back-patching.

17 years agoUpdate timezone mapping for Windows with new timezones added
Magnus Hagander [Mon, 11 Feb 2008 19:55:11 +0000 (19:55 +0000)]
Update timezone mapping for Windows with new timezones added
in windows servicepacks.
Fix timezone mapping for "Mexico 2"

17 years agoRepair VACUUM FULL bug introduced by HOT patch: the original way of
Tom Lane [Mon, 11 Feb 2008 19:14:30 +0000 (19:14 +0000)]
Repair VACUUM FULL bug introduced by HOT patch: the original way of
calculating a page's initial free space was fine, and should not have been
"improved" by letting PageGetHeapFreeSpace do it.  VACUUM FULL is going to
reclaim LP_DEAD line pointers later, so there is no need for a guard
against the page being too full of line pointers, and having one risks
rejecting pages that are perfectly good move destinations.

This also exposed a second bug, which is that the empty_end_pages logic
assumed that any page with no live tuples would get entered into the
fraged_pages list automatically (by virtue of having more free space than
the threshold in the do_frag calculation).  This assumption certainly
seems risky when a low fillfactor has been chosen, and even without
tunable fillfactor I think it could conceivably fail on a page with many
unused line pointers.  So fix the code to force do_frag true when notup
is true, and patch this part of the fix all the way back.

Per report from Tomas Szepe.