]> granicus.if.org Git - postgresql/log
postgresql
17 years agoDraft release notes for upcoming back-branch updates.
Tom Lane [Wed, 4 Jun 2008 03:16:11 +0000 (03:16 +0000)]
Draft release notes for upcoming back-branch updates.

17 years agoRemove unused variable (was already done in HEAD)
Tom Lane [Tue, 3 Jun 2008 20:55:41 +0000 (20:55 +0000)]
Remove unused variable (was already done in HEAD)

17 years agoFix initdb to reject a relative path for -X (--xlogdir) argument. This
Tom Lane [Mon, 2 Jun 2008 03:48:07 +0000 (03:48 +0000)]
Fix initdb to reject a relative path for -X (--xlogdir) argument.  This
doesn't work, and the real reason why not is it's unclear where the path
is relative to (initdb's CWD, or the data directory?).  We could make an
arbitrary decision, but it seems best to make the user be unambiguous.
Per gripe from Devrim.

17 years agoUpdate time zone data files to tzdata release 2008c (DST law changes in
Tom Lane [Sun, 1 Jun 2008 18:23:07 +0000 (18:23 +0000)]
Update time zone data files to tzdata release 2008c (DST law changes in
Morocco, Iraq, Choibalsan, Pakistan, Syria, Cuba, Argentina/San_Luis).

17 years agoMake 8.3.x psql print tab characters as an appropriate number of spaces,
Tom Lane [Thu, 29 May 2008 19:34:44 +0000 (19:34 +0000)]
Make 8.3.x psql print tab characters as an appropriate number of spaces,
rather than "\x09".  Before 8.3 we just printed tabs as-is, leading to poor
formatting of subsequent columns, but consensus is that "\x09" is not an
improvement over that.  Back-patch of fix that's already in HEAD.

17 years agoFix some bugs introduced by the 8.2-era conversion of cube functions to V1
Tom Lane [Thu, 29 May 2008 18:46:46 +0000 (18:46 +0000)]
Fix some bugs introduced by the 8.2-era conversion of cube functions to V1
calling convention.  cube_inter and cube_distance could attempt to pfree
their input arguments, and cube_dim returned a value from a struct it
might have just pfree'd (which would only really cause a problem in a
debug build, but it's still wrong).  Per bug #4208 and additional code
reading.

In HEAD and 8.3, I also made a batch of cosmetic changes to bring these
functions into line with the preferred coding style for V1 functions,
ie declare and fetch all the arguments at the top so readers can easily
see what they are.

17 years agoBackpatch Zdenek Kotala's fix to prevent pglz_decompress from stomping on
Tom Lane [Wed, 28 May 2008 21:58:03 +0000 (21:58 +0000)]
Backpatch Zdenek Kotala's fix to prevent pglz_decompress from stomping on
memory if the compressed data is corrupt.

Backpatch as far as 8.2.  The issue exists in older branches too, but given
the lack of field reports, it's not clear it's worth any additional effort
to adapt the patch to the slightly different code in older branches.

17 years agoImprove GRANT documentation to point out that UPDATE and DELETE typically
Tom Lane [Wed, 28 May 2008 00:45:47 +0000 (00:45 +0000)]
Improve GRANT documentation to point out that UPDATE and DELETE typically
require SELECT privilege as well, since you normally need to read existing
column values within such commands.  This behavior is according to spec,
but we'd never documented it before.  Per gripe from Volkan Yazici.

17 years agoRequire bind_textdomain_codeset() not just gettext() to enable NLS support.
Tom Lane [Tue, 27 May 2008 22:18:11 +0000 (22:18 +0000)]
Require bind_textdomain_codeset() not just gettext() to enable NLS support.
GNU gettext before 0.10.36 does not have that function, and is generally too
incomplete to be usable.

17 years agoClarify description of typmod input function, per Jeff Davis.
Tom Lane [Tue, 27 May 2008 18:05:20 +0000 (18:05 +0000)]
Clarify description of typmod input function, per Jeff Davis.

17 years agoExplicitly bind gettext() to the UTF8 locale when in use.
Magnus Hagander [Tue, 27 May 2008 12:24:46 +0000 (12:24 +0000)]
Explicitly bind gettext() to the  UTF8 locale when in use.
This is required on Windows due to the special locale
handling for UTF8 that doesn't change the full environment.

Fixes crash with translated error messages per bugs 4180
and 4196.

Tom Lane

17 years agoFix an old corner-case bug in set_config_option: push_old_value has to be
Tom Lane [Mon, 26 May 2008 18:54:36 +0000 (18:54 +0000)]
Fix an old corner-case bug in set_config_option: push_old_value has to be
called before, not after, calling the assign_hook if any.  This is because
push_old_value might fail (due to palloc out-of-memory), and in that case
there would be no stack entry to tell transaction abort to undo the GUC
assignment.  Of course the actual assignment to the GUC variable hasn't
happened yet --- but the assign_hook might have altered subsidiary state.
Without a stack entry we won't call it again to make it undo such actions.
So this is necessary to make the world safe for assign_hooks with side
effects.  Per a discussion a couple weeks ago with Magnus.

Back-patch to 8.0.  7.x did not have the problem because it did not have
allocatable stacks of GUC values.

17 years agoAdjust timestamp regression tests to prevent two low-probability failure
Tom Lane [Sun, 25 May 2008 21:51:11 +0000 (21:51 +0000)]
Adjust timestamp regression tests to prevent two low-probability failure
cases.  Recent buildfarm experience shows that it is sometimes possible
to execute several SQL commands in less time than the granularity of
Windows' not-very-high-resolution gettimeofday(), leading to a failure
because the tests expect the value of now() to change and it doesn't.
Also, it was recognized some time ago that the same area of the tests
could fail if local midnight passes between the insertion and the checking
of the values for 'yesterday', 'tomorrow', etc.  Clean all this up per
ideas from myself and Greg Stark.

There remains a window for failure if the transaction block is entered
exactly at local midnight (so that 'now' and 'today' have the same value),
but that seems low-probability enough to live with.

Since the point of this change is mostly to eliminate buildfarm noise,
back-patch to all versions we are still actively testing.

17 years agoRemove arbitrary 10MB limit on two-phase state file size. It's not that hard
Heikki Linnakangas [Mon, 19 May 2008 18:16:46 +0000 (18:16 +0000)]
Remove arbitrary 10MB limit on two-phase state file size. It's not that hard
to go beoynd 10MB, as demonstrated by Gavin Sharry's example of dropping a
schema with ~25000 objects. The really bogus thing about the limit was that
it was enforced when a state file file was read in, not when it was written,
so you would end up with a prepared transaction that you can't commit or
abort, and the only recourse was to shut down the server and remove the file
by hand.

Raise the limit to MaxAllocSize, and enforce it also when a state file is
written. We could've removed the limit altogether, but reading in a file
larger than MaxAllocSize would fail anyway because we read it into a
palloc'd buffer.

Backpatch down to 8.1, where 2PC and this issue was introduced.

17 years agoCoercion sanity check in ri_HashCompareOp failed to allow for enums, as per
Tom Lane [Mon, 19 May 2008 04:14:33 +0000 (04:14 +0000)]
Coercion sanity check in ri_HashCompareOp failed to allow for enums, as per
example from Rod Taylor.  On reflection the correct test here is for any
polymorphic type, not specifically ANYARRAY as in the original coding.

17 years agoAdd code to eval_const_expressions() to support const-simplification of
Tom Lane [Thu, 15 May 2008 17:37:57 +0000 (17:37 +0000)]
Add code to eval_const_expressions() to support const-simplification of
CoerceViaIO nodes.  This improves the ability of the planner to deal with
cases where the node input is a constant.  Per bug #4170.

17 years agoDon't try to close negative file descriptors, since this can cause
Magnus Hagander [Tue, 13 May 2008 20:54:02 +0000 (20:54 +0000)]
Don't try to close negative file descriptors, since this can cause
crashes on certain platforms. In particular, the MSVC runtime is known
to do this.

Fixes bug #4162, reported and diagnosed by Javier Pimas

17 years agoCheck for non-existant connection in prepare statement handling.
Michael Meskes [Mon, 12 May 2008 16:30:17 +0000 (16:30 +0000)]
Check for non-existant connection in prepare statement handling.
Do not close files that weren't opened.

17 years agoBackpatch fixes for contrib makefiles.
Andrew Dunstan [Sat, 10 May 2008 16:07:56 +0000 (16:07 +0000)]
Backpatch fixes for contrib makefiles.

17 years agoFix an ancient oversight in change_varattnos_of_a_node: it neglected to update
Tom Lane [Fri, 9 May 2008 22:37:34 +0000 (22:37 +0000)]
Fix an ancient oversight in change_varattnos_of_a_node: it neglected to update
varoattno along with varattno.  This resulted in having Vars that were not
seen as equal(), causing inheritance of the "same" constraint from different
parent relations to fail.  An example is

create table pp1 (f1 int check (f1>0));
create table cc1 (f2 text, f3 int) inherits (pp1);
create table cc2(f4 float) inherits(pp1,cc1);

Backpatch as far as 7.4.  (The test case still fails in 7.4, for reasons
that I don't feel like investigating at the moment.)

This is a backpatch commit only.  The fix will be applied in HEAD as part
of the upcoming pg_constraint patch.

17 years agoFix Assert introduced in previous patch.
Heikki Linnakangas [Fri, 9 May 2008 15:28:01 +0000 (15:28 +0000)]
Fix Assert introduced in previous patch.

17 years agoFix incorrect archive truncation point calculation in the %r recovery_command
Heikki Linnakangas [Fri, 9 May 2008 14:28:08 +0000 (14:28 +0000)]
Fix incorrect archive truncation point calculation in the %r recovery_command
parameter. This fixes bug 4137 reported by Wojciech Strzalka, where a WAL
file is deleted too early when starting the recovery of a warm standby server.

Also add a sanity check in pg_standby so that it will refuse to delete anything
earlier than the file being restored, and improve the debug message in case
nothing is deleted.

Simon Riggs. Backpatch to 8.3, which is where %r was introduced.

17 years agoFix contrib/xml2 makefile to not override CFLAGS, and in passing make it
Tom Lane [Thu, 8 May 2008 16:49:48 +0000 (16:49 +0000)]
Fix contrib/xml2 makefile to not override CFLAGS, and in passing make it
auto-configure properly for libxslt present or not.

17 years agoAdd Simon Riggs' email address.
Alvaro Herrera [Wed, 7 May 2008 22:06:11 +0000 (22:06 +0000)]
Add Simon Riggs' email address.

17 years agoAdd more dependencies from libpgport required by
Magnus Hagander [Mon, 5 May 2008 19:31:45 +0000 (19:31 +0000)]
Add more dependencies from libpgport required by
standalone msvc build of libpq.

Hiroshi Saito

17 years agoThe 8.2 patch that added support for an alias on the target table of
Tom Lane [Sat, 3 May 2008 23:19:27 +0000 (23:19 +0000)]
The 8.2 patch that added support for an alias on the target table of
UPDATE/DELETE forgot to teach ruleutils.c to display the alias.
Per bug #4141 from Mathias Seiler.

17 years agoFix nodeTidscan.c to not trigger an error if the block number portion of
Tom Lane [Wed, 30 Apr 2008 23:28:37 +0000 (23:28 +0000)]
Fix nodeTidscan.c to not trigger an error if the block number portion of
a user-supplied TID is out of range for the relation.  This is needed to
preserve compatibility with our pre-8.3 behavior, and it is sensible anyway
since if the query were implemented by brute force rather than optimized
into a TidScan, the behavior for a non-existent TID would be zero rows out,
never an error.  Per gripe from Gurjeet Singh.

17 years agoFix REASSIGN OWNED so that it works on procedural languages too.
Alvaro Herrera [Tue, 29 Apr 2008 19:37:13 +0000 (19:37 +0000)]
Fix REASSIGN OWNED so that it works on procedural languages too.

The capability for changing language owners is new in 8.3, so that's how
far back this needs to be backpatched.

Per bug #4132 by Kirill Simonov.

17 years agoFix broken configure test for libxslt: it was probing for xsltLibxmlVersion,
Tom Lane [Mon, 28 Apr 2008 22:47:11 +0000 (22:47 +0000)]
Fix broken configure test for libxslt: it was probing for xsltLibxmlVersion,
which is a global variable not a function, and so the probe failed on machines
where the linker makes a distinction (cf. Red Hat bug #444317).  Probe for
an actual function instead.

17 years agoBack-patch Heikki's fix to make TransactionIdIsCurrentTransactionId() use
Tom Lane [Sat, 26 Apr 2008 23:35:33 +0000 (23:35 +0000)]
Back-patch Heikki's fix to make TransactionIdIsCurrentTransactionId() use
binary search instead of linear search when checking child-transaction XIDs.
Per example from Robert Treat, the speed of TransactionIdIsCurrentTransactionId
is significantly more important in 8.3 than it was in prior releases, so
this seems worth taking back-patching risk for.

17 years agoFix ALTER TABLE ADD COLUMN ... PRIMARY KEY so that the new column is correctly
Tom Lane [Thu, 24 Apr 2008 20:17:59 +0000 (20:17 +0000)]
Fix ALTER TABLE ADD COLUMN ... PRIMARY KEY so that the new column is correctly
checked to see if it's been initialized to all non-nulls.  The implicit NOT
NULL constraint was not being checked during the ALTER (in fact, not even if
there was an explicit NOT NULL too), because ATExecAddColumn neglected to
set the flag needed to make the test happen.  This has been broken since
the capability was first added, in 8.0.

Brendan Jurd, per a report from Kaloyan Iliev.

17 years agoFix using too many LWLocks bug, reported by Craig Ringer
Teodor Sigaev [Tue, 22 Apr 2008 17:54:19 +0000 (17:54 +0000)]
Fix using too many LWLocks bug, reported by Craig Ringer
<craig@postnewspapers.com.au>.
It was my mistake, I missed limitation of number of held locks, now GIN doesn't
use continiuous locks, but still hold buffers pinned to prevent interference
with vacuum's deletion algorithm.

17 years agoReplace developer FAQ with a reference to the wiki, which is where
Magnus Hagander [Tue, 22 Apr 2008 09:26:45 +0000 (09:26 +0000)]
Replace developer FAQ with a reference to the wiki, which is where
it now lives (per discussion). Leave the other FAQs alone for now.

17 years agoFix convert_IN_to_join to properly handle the case where the subselect's
Tom Lane [Mon, 21 Apr 2008 20:54:24 +0000 (20:54 +0000)]
Fix convert_IN_to_join to properly handle the case where the subselect's
output is not of the same type that's needed for the IN comparison (ie,
where the parser inserted an implicit coercion above the subselect result).
We should record the coerced expression, not just a raw Var referencing
the subselect output, as the quantity that needs to be unique-ified if
we choose to implement the IN as Unique followed by a plain join.

As of 8.3 this error was causing crashes, as seen in bug #4113 from Javier
Hernandez, because the executor was being told to hash or sort the raw
subselect output column using operators appropriate to the coerced type.

In prior versions there was no crash because the executor chose the
hash or sort operators for itself based on the column type it saw.
However, that's still not really right, because what's unique for one data
type might not be unique for another.  In corner cases we could get multiple
outputs of a row that should appear only once, as demonstrated by the
regression test case included in this commit.

However, this patch doesn't apply cleanly to 8.2 or before, and the code
involved has shifted enough over time that I'm hesitant to try to back-patch.
Given the lack of complaints from the field about such corner cases, I think
the bug may not be important enough to risk breaking other things with a
back-patch.

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.