]> granicus.if.org Git - postgresql/log
postgresql
13 years agoTag 8.1.23. REL8_1_STABLE github/REL8_1_STABLE REL8_1_23
Marc G. Fournier [Tue, 14 Dec 2010 03:52:30 +0000 (23:52 -0400)]
Tag 8.1.23.

13 years agoTag 8.1.23.
Marc G. Fournier [Tue, 14 Dec 2010 03:06:55 +0000 (23:06 -0400)]
Tag 8.1.23.

13 years agoUpdate release notes for releases 9.0.2, 8.4.6, 8.3.13, 8.2.19, and 8.1.23.
Tom Lane [Tue, 14 Dec 2010 01:22:13 +0000 (20:22 -0500)]
Update release notes for releases 9.0.2, 8.4.6, 8.3.13, 8.2.19, and 8.1.23.

13 years agoTranslation updates for release 8.1.23
Peter Eisentraut [Mon, 13 Dec 2010 20:29:08 +0000 (22:29 +0200)]
Translation updates for release 8.1.23

13 years agoUpdate time zone data files to tzdata release 2010o: DST law changes in
Tom Lane [Mon, 13 Dec 2010 17:41:57 +0000 (12:41 -0500)]
Update time zone data files to tzdata release 2010o: DST law changes in
Fiji and Samoa.  Historical corrections for Hong Kong.

13 years agoForce default wal_sync_method to be fdatasync on Linux.
Tom Lane [Thu, 9 Dec 2010 01:01:33 +0000 (20:01 -0500)]
Force default wal_sync_method to be fdatasync on Linux.

Recent versions of the Linux system header files cause xlogdefs.h to
believe that open_datasync should be the default sync method, whereas
formerly fdatasync was the default on Linux.  open_datasync is a bad
choice, first because it doesn't actually outperform fdatasync (in fact
the reverse), and second because we try to use O_DIRECT with it, causing
failures on certain filesystems (e.g., ext4 with data=journal option).
This part of the patch is largely per a proposal from Marti Raudsepp.
More extensive changes are likely to follow in HEAD, but this is as much
change as we want to back-patch.

Also clean up confusing code and incorrect documentation surrounding the
fsync_writethrough option.  Those changes shouldn't result in any actual
behavioral change, but I chose to back-patch them anyway to keep the
branches looking similar in this area.

In 9.0 and HEAD, also do some copy-editing on the WAL Reliability
documentation section.

Back-patch to all supported branches, since any of them might get used
on modern Linux versions.

13 years agoAdd a stack overflow check to copyObject().
Tom Lane [Tue, 7 Dec 2010 03:56:12 +0000 (22:56 -0500)]
Add a stack overflow check to copyObject().

There are some code paths, such as SPI_execute(), where we invoke
copyObject() on raw parse trees before doing parse analysis on them.  Since
the bison grammar is capable of building heavily nested parsetrees while
itself using only minimal stack depth, this means that copyObject() can be
the front-line function that hits stack overflow before anything else does.
Accordingly, it had better have a check_stack_depth() call.  I did a bit of
performance testing and found that this slows down copyObject() by only a
few percent, so the hit ought to be negligible in the context of complete
processing of a query.

Per off-list report from Toshihide Katayama.  Back-patch to all supported
branches.

13 years agoPrevent inlining a SQL function with multiple OUT parameters.
Tom Lane [Wed, 1 Dec 2010 05:53:44 +0000 (00:53 -0500)]
Prevent inlining a SQL function with multiple OUT parameters.

There were corner cases in which the planner would attempt to inline such
a function, which would result in a failure at runtime due to loss of
information about exactly what the result record type is.  Fix by disabling
inlining when the function's recorded result type is RECORD.  There might
be some sub-cases where inlining could still be allowed, but this is a
simple and backpatchable fix, so leave refinements for another day.
Per bug #5777 from Nate Carson.

Back-patch to all supported branches.  8.1 happens to avoid a core-dump
here, but it still does the wrong thing.

13 years agoFix significant memory leak in contrib/xml2 functions.
Tom Lane [Fri, 26 Nov 2010 20:21:12 +0000 (15:21 -0500)]
Fix significant memory leak in contrib/xml2 functions.

Most of the functions that execute XPath queries leaked the data structures
created by libxml2.  This memory would not be recovered until end of
session, so it mounts up pretty quickly in any serious use of the feature.
Per report from Pavel Stehule, though this isn't his patch.

Back-patch to all supported branches.

13 years agoDon't raise "identifier will be truncated" messages in dblink
Itagaki Takahiro [Thu, 25 Nov 2010 11:12:20 +0000 (20:12 +0900)]
Don't raise "identifier will be truncated" messages in dblink
except creating new connections.

13 years agoThe GiST scan algorithm uses LSNs to detect concurrent pages splits, but
Heikki Linnakangas [Tue, 16 Nov 2010 09:02:11 +0000 (11:02 +0200)]
The GiST scan algorithm uses LSNs to detect concurrent pages splits, but
temporary indexes are not WAL-logged. We used a constant LSN for temporary
indexes, on the assumption that we don't need to worry about concurrent page
splits in temporary indexes because they're only visible to the current
session. But that assumption is wrong, it's possible to insert rows and
split pages in the same session, while a scan is in progress. For example,
by opening a cursor and fetching some rows, and INSERTing new rows before
fetching some more.

Fix by generating fake increasing LSNs, used in place of real LSNs in
temporary GiST indexes.

13 years agoFix bug in cube picksplit algorithm.
Robert Haas [Mon, 15 Nov 2010 02:27:34 +0000 (21:27 -0500)]
Fix bug in cube picksplit algorithm.

Alexander Korotkov

13 years agoAdd missing outfuncs.c support for struct InhRelation.
Tom Lane [Sat, 13 Nov 2010 05:35:13 +0000 (00:35 -0500)]
Add missing outfuncs.c support for struct InhRelation.

This is needed to support debug_print_parse, per report from Jon Nelson.
Cursory testing via the regression tests suggests we aren't missing
anything else.

13 years agoFix old oversight in const-simplification of COALESCE() expressions.
Tom Lane [Fri, 12 Nov 2010 20:14:51 +0000 (15:14 -0500)]
Fix old oversight in const-simplification of COALESCE() expressions.

Once we have found a non-null constant argument, there is no need to
examine additional arguments of the COALESCE.  The previous coding got it
right only if the constant was in the first argument position; otherwise
it tried to simplify following arguments too, leading to unexpected
behavior like this:

regression=# select coalesce(f1, 42, 1/0) from int4_tbl;
ERROR:  division by zero

It's a minor corner case, but a bug is a bug, so back-patch all the way.

13 years agoFix bug introduced by the recent patch to check that the checkpoint redo
Heikki Linnakangas [Thu, 11 Nov 2010 17:21:49 +0000 (19:21 +0200)]
Fix bug introduced by the recent patch to check that the checkpoint redo
location read from backup label file can be found: wasShutdown was set
incorrectly when a backup label file was found.

Jeff Davis, with a little tweaking by me.

13 years agoFix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.
Tom Lane [Wed, 10 Nov 2010 21:51:39 +0000 (16:51 -0500)]
Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.

This code was just plain wrong: what you got was not a line through the
given point but a line almost indistinguishable from the Y-axis, although
not truly vertical.  The only caller that tries to use this function with
m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal;
it would end up producing the distance from the given point to the place
where the lseg's line crosses the Y-axis.  That function is used by other
operators too, so there are several operators that could compute wrong
distances from a line segment to something else.  Per bug #5745 from
jindiax.

Back-patch to all supported branches.

13 years agoRepair memory leakage while ANALYZE-ing complex index expressions.
Tom Lane [Tue, 9 Nov 2010 16:28:18 +0000 (11:28 -0500)]
Repair memory leakage while ANALYZE-ing complex index expressions.

The general design of memory management in Postgres is that intermediate
results computed by an expression are not freed until the end of the tuple
cycle.  For expression indexes, ANALYZE has to re-evaluate each expression
for each of its sample rows, and it wasn't bothering to free intermediate
results until the end of processing of that index.  This could lead to very
substantial leakage if the intermediate results were large, as in a recent
example from Jakub Ouhrabka.  Fix by doing ResetExprContext for each sample
row.  This necessitates adding a datumCopy step to ensure that the final
expression value isn't recycled too.  Some quick testing suggests that this
change adds at worst about 10% to the time needed to analyze a table with
an expression index; which is annoying, but seems a tolerable price to pay
to avoid unexpected out-of-memory problems.

Back-patch to all supported branches.

13 years agoAdd support for detecting register-stack overrun on IA64.
Tom Lane [Sun, 7 Nov 2010 02:59:31 +0000 (22:59 -0400)]
Add support for detecting register-stack overrun on IA64.

Per recent investigation, the register stack can grow faster than the
regular stack depending on compiler and choice of options.  To avoid
crashes we must check both stacks in check_stack_depth().

Back-patch to all supported versions.

13 years agoReduce recursion depth in recently-added regression test.
Tom Lane [Wed, 3 Nov 2010 17:42:24 +0000 (13:42 -0400)]
Reduce recursion depth in recently-added regression test.

Some buildfarm members fail the test with the original depth of 10 levels,
apparently because they are running at the minimum max_stack_depth setting
of 100kB and using ~ 10k per recursion level.  While it might be
interesting to try to figure out why they're eating so much stack, it isn't
likely that any fix for that would be back-patchable.  So just change the
test to recurse only 5 levels.  The extra levels don't prove anything
correctness-wise anyway.

13 years agoEnsure an index that uses a whole-row Var still depends on its table.
Tom Lane [Tue, 2 Nov 2010 21:15:35 +0000 (17:15 -0400)]
Ensure an index that uses a whole-row Var still depends on its table.

We failed to record any dependency on the underlying table for an index
declared like "create index i on t (foo(t.*))".  This would create trouble
if the table were dropped without previously dropping the index.  To fix,
simplify some overly-cute code in index_create(), accepting the possibility
that sometimes the whole-table dependency will be redundant.  Also document
this hazard in dependency.c.  Per report from Kevin Grittner.

In passing, prevent a core dump in pg_get_indexdef() if the index's table
can't be found.  I came across this while experimenting with Kevin's
example.  Not sure it's a real issue when the catalogs aren't corrupt, but
might as well be cautious.

Back-patch to all supported versions.

13 years agoFix plpgsql's handling of "simple" expression evaluation.
Tom Lane [Thu, 28 Oct 2010 17:01:28 +0000 (13:01 -0400)]
Fix plpgsql's handling of "simple" expression evaluation.

In general, expression execution state trees aren't re-entrantly usable,
since functions can store private state information in them.
For efficiency reasons, plpgsql tries to cache and reuse state trees for
"simple" expressions.  It can get away with that most of the time, but it
can fail if the state tree is dirty from a previous failed execution (as
in an example from Alvaro) or is being used recursively (as noted by me).

Fix by tracking whether a state tree is in use, and falling back to the
"non-simple" code path if so.  This results in a pretty considerable speed
hit when the non-simple path is taken, but the available alternatives seem
even more unpleasant because they add overhead in the simple path.  Per
idea from Heikki.

Back-patch to all supported branches.

13 years agoBefore removing backup_label and irrevocably changing pg_control file, check
Heikki Linnakangas [Tue, 26 Oct 2010 18:15:42 +0000 (21:15 +0300)]
Before removing backup_label and irrevocably changing pg_control file, check
that WAL file containing the checkpoint redo-location can be found. This
avoids making the cluster irrecoverable if the redo location is in an earlie
WAL file than the checkpoint record.

Report, analysis and patch by Jeff Davis, with small changes by me.

13 years agoIf pk is NULL, the backend would segfault when accessing ->algo and the
Heikki Linnakangas [Wed, 20 Oct 2010 19:20:33 +0000 (22:20 +0300)]
If pk is NULL, the backend would segfault when accessing ->algo and the
following NULL check was never reached.

This problem was found by Coccinelle (null_ref.cocci from coccicheck).

Marti Raudsepp

13 years agoWarn that views can be safely used to hide columns, but not rows.
Robert Haas [Fri, 8 Oct 2010 13:15:17 +0000 (09:15 -0400)]
Warn that views can be safely used to hide columns, but not rows.

13 years agoTag 8.1.22 REL8_1_22
Marc G. Fournier [Fri, 1 Oct 2010 13:37:59 +0000 (10:37 -0300)]
Tag 8.1.22

13 years agoUse a separate interpreter for each calling SQL userid in plperl and pltcl.
Tom Lane [Thu, 30 Sep 2010 21:21:59 +0000 (17:21 -0400)]
Use a separate interpreter for each calling SQL userid in plperl and pltcl.

There are numerous methods by which a Perl or Tcl function can subvert
the behavior of another such function executed later; for example, by
redefining standard functions or operators called by the target function.
If the target function is SECURITY DEFINER, or is called by such a
function, this means that any ordinary SQL user with Perl or Tcl language
usage rights can do essentially anything with the privileges of the target
function's owner.

To close this security hole, create a separate Perl or Tcl interpreter for
each SQL userid under which plperl or pltcl functions are executed within
a session.  However, all plperlu or pltclu functions run within a session
still share a single interpreter, since they all execute at the trust
level of a database superuser anyway.

Note: this change results in a functionality loss when libperl has been
built without the "multiplicity" option: it's no longer possible to call
plperl functions under different userids in one session, since such a
libperl can't support multiple interpreters in one process.  However, such
a libperl already failed to support concurrent use of plperl and plperlu,
so it's likely that few people use such versions with Postgres.

Security: CVE-2010-3433

13 years agoTranslation updates for 8.1.22
Peter Eisentraut [Thu, 30 Sep 2010 19:15:37 +0000 (22:15 +0300)]
Translation updates for 8.1.22

13 years agoUpdate release notes for releases 9.0.1, 8.4.5, 8.3.12, 8.2.18, 8.1.22,
Tom Lane [Thu, 30 Sep 2010 18:27:51 +0000 (14:27 -0400)]
Update release notes for releases 9.0.1, 8.4.5, 8.3.12, 8.2.18, 8.1.22,
8.0.26, and 7.4.30.

13 years agoFurther fixes to the pg_get_expr() security fix in back branches.
Tom Lane [Sat, 25 Sep 2010 19:57:05 +0000 (15:57 -0400)]
Further fixes to the pg_get_expr() security fix in back branches.

It now emerges that the JDBC driver expects to be able to use pg_get_expr()
on an output of a sub-SELECT.  So extend the check logic to be able to recurse
into a sub-SELECT to see if the argument is ultimately coming from an
appropriate column.  Per report from Thomas Kellerer.

13 years agoStill more .gitignore cleanup.
Tom Lane [Fri, 24 Sep 2010 17:48:37 +0000 (13:48 -0400)]
Still more .gitignore cleanup.

Fix overly-enthusiastic ignores, as identified by
git ls-files -i --exclude-standard

13 years agoAdd contrib/xml2/pgxml.sql to .gitignore
Robert Haas [Fri, 24 Sep 2010 02:00:26 +0000 (22:00 -0400)]
Add contrib/xml2/pgxml.sql to .gitignore

Kevin Grittner

13 years agoPrevent show_session_authorization from crashing when session_authorization
Tom Lane [Thu, 23 Sep 2010 20:53:42 +0000 (16:53 -0400)]
Prevent show_session_authorization from crashing when session_authorization
hasn't been set.

The only known case where this can happen is when show_session_authorization
is invoked in an autovacuum process, which is possible if an index function
calls it, as for example in bug #5669 from Andrew Geery.  We could perhaps
try to return a sensible value, such as the name of the cluster-owning
superuser; but that seems like much more trouble than the case is worth,
and in any case it could create new possible failure modes.  Simply
returning an empty string seems like the most appropriate fix.

Back-patch to all supported versions, even those before autovacuum, just
in case there's another way to provoke this crash.

13 years agoMore fixes for libpq's .gitignore file.
Tom Lane [Thu, 23 Sep 2010 02:32:54 +0000 (22:32 -0400)]
More fixes for libpq's .gitignore file.

The previous patches failed to cover a lot of symlinks that are only
added in platform-specific cases.  Make the lists match what's in the
Makefile for each branch.

13 years agoDo some copy-editing on the Git usage docs.
Tom Lane [Thu, 23 Sep 2010 00:22:55 +0000 (20:22 -0400)]
Do some copy-editing on the Git usage docs.

13 years agoFix documentation gitignore for pre-9.0 doc build methods.
Tom Lane [Wed, 22 Sep 2010 22:26:29 +0000 (18:26 -0400)]
Fix documentation gitignore for pre-9.0 doc build methods.

13 years agoSome more gitignore cleanups: cover contrib and PL regression test outputs.
Tom Lane [Wed, 22 Sep 2010 21:22:18 +0000 (17:22 -0400)]
Some more gitignore cleanups: cover contrib and PL regression test outputs.

Also do some further work in the back branches, where quite a bit wasn't
covered by Magnus' original back-patch.

13 years agoRemove anonymous cvs instructions, and replace them with instructions
Magnus Hagander [Wed, 22 Sep 2010 18:48:47 +0000 (20:48 +0200)]
Remove anonymous cvs instructions, and replace them with instructions
for git. Change other references from cvs to git as well.

13 years agoConvert cvsignore to gitignore, and add .gitignore for build targets.
Magnus Hagander [Wed, 22 Sep 2010 10:57:17 +0000 (12:57 +0200)]
Convert cvsignore to gitignore, and add .gitignore for build targets.

13 years agoBack-patch replacement of README.CVS with README.git.
Tom Lane [Tue, 21 Sep 2010 18:43:20 +0000 (14:43 -0400)]
Back-patch replacement of README.CVS with README.git.

In older branches, also git-ify the "make distdir" rule.

13 years agoUpdate time zone data files to tzdata release 2010l: DST law changes in
Tom Lane [Thu, 26 Aug 2010 19:59:22 +0000 (19:59 +0000)]
Update time zone data files to tzdata release 2010l: DST law changes in
Egypt and Palestine.  Added new names for two Micronesian timezones:
Pacific/Chuuk is now preferred over Pacific/Truk (and the preferred
abbreviation is CHUT not TRUT) and Pacific/Pohnpei is preferred over
Pacific/Ponape.  Historical corrections for Finland.

13 years agoFix ExecMakeTableFunctionResult to verify that all rows returned by a SRF
Tom Lane [Thu, 26 Aug 2010 18:55:12 +0000 (18:55 +0000)]
Fix ExecMakeTableFunctionResult to verify that all rows returned by a SRF
returning "record" actually do have the same rowtype.  This is needed because
the parser can't realistically enforce that they will all have the same typmod,
as seen in a recent example from David Wheeler.

Back-patch to 8.0, which is as far back as we have the notion of RECORD
subtypes being distinguished by typmod.  Wheeler's example depends on
8.4-and-up features, but I suspect there may be ways to provoke similar
failures before 8.4.

13 years agoCatch null pointer returns from PyCObject_AsVoidPtr and PyCObject_FromVoidPtr
Peter Eisentraut [Wed, 25 Aug 2010 19:37:34 +0000 (19:37 +0000)]
Catch null pointer returns from PyCObject_AsVoidPtr and PyCObject_FromVoidPtr

This is reproducibly possible in Python 2.7 if the user turned
PendingDeprecationWarning into an error, but it's theoretically also possible
in earlier versions in case of exceptional conditions.

backpatched to 8.0

13 years agoArrange to fsync the contents of lockfiles (both postmaster.pid and the
Tom Lane [Mon, 16 Aug 2010 17:33:17 +0000 (17:33 +0000)]
Arrange to fsync the contents of lockfiles (both postmaster.pid and the
socket lockfile) when writing them.  The lack of an fsync here may well
explain two different reports we've seen of corrupted lockfile contents,
which doesn't particularly bother the running server but can prevent a
new server from starting if the old one crashes.  Per suggestion from
Alvaro.

Back-patch to all supported versions.

13 years agoFix psql's copy of utf2ucs() to match the backend's copy exactly;
Tom Lane [Mon, 16 Aug 2010 00:06:48 +0000 (00:06 +0000)]
Fix psql's copy of utf2ucs() to match the backend's copy exactly;
in particular, propagate a fix in the test to see whether a UTF8 character has
length 4 bytes.  This is likely of little real-world consequence because
5-or-more-byte UTF8 sequences are not supported by Postgres nor seen anywhere
in the wild, but still we may as well get it right.  Problem found by Joseph
Adams.

Bug is aboriginal, so back-patch all the way.

13 years agoFix one more incorrect errno definition in the ECPG manual.
Robert Haas [Wed, 11 Aug 2010 19:04:03 +0000 (19:04 +0000)]
Fix one more incorrect errno definition in the ECPG manual.

Again, back-patch all the way to 7.4.

13 years agoFix incorrect errno definitions in ECPG manual.
Robert Haas [Wed, 11 Aug 2010 18:52:52 +0000 (18:52 +0000)]
Fix incorrect errno definitions in ECPG manual.

ecpgerrno.h hasn't materially changed since PostgreSQL 7.4, so this has
been wrong for a very long time.  Back-patch all the way.

Satoshi Nagayasu

13 years agoFix incorrect logic in plpgsql for cleanup after evaluation of non-simple
Tom Lane [Mon, 9 Aug 2010 18:50:54 +0000 (18:50 +0000)]
Fix incorrect logic in plpgsql for cleanup after evaluation of non-simple
expressions.  We need to deal with this when handling subscripts in an array
assignment, and also when catching an exception.  In an Assert-enabled build
these omissions led to Assert failures, but I think in a normal build the
only consequence would be short-term memory leakage; which may explain why
this wasn't reported from the field long ago.

Back-patch to all supported versions.  7.4 doesn't have exceptions, but
otherwise these bugs go all the way back.

Heikki Linnakangas and Tom Lane

13 years agoImproved version of patch to protect pg_get_expr() against misuse:
Tom Lane [Fri, 30 Jul 2010 17:57:18 +0000 (17:57 +0000)]
Improved version of patch to protect pg_get_expr() against misuse:
look through join alias Vars to avoid breaking join queries, and
move the test to someplace where it will catch more possible ways
of calling a function.  We still ought to throw away the whole thing
in favor of a data-type-based solution, but that's not feasible in
the back branches.

Completion of back-port of my patch of yesterday.

13 years agoFix another longstanding problem in copy_relation_data: it was blithely
Tom Lane [Thu, 29 Jul 2010 19:23:58 +0000 (19:23 +0000)]
Fix another longstanding problem in copy_relation_data: it was blithely
assuming that a local char[] array would be aligned on at least a word
boundary.  There are architectures on which that is pretty much guaranteed to
NOT be the case ... and those arches also don't like non-aligned memory
accesses, meaning that log_newpage() would crash if it ever got invoked.
Even on Intel-ish machines there's a potential for a large performance penalty
from doing I/O to an inadequately aligned buffer.  So palloc it instead.

Backpatch to 8.0 --- 7.4 doesn't have this code.

13 years agoFix possible page corruption by ALTER TABLE .. SET TABLESPACE.
Robert Haas [Thu, 29 Jul 2010 16:15:33 +0000 (16:15 +0000)]
Fix possible page corruption by ALTER TABLE .. SET TABLESPACE.

If a zeroed page is present in the heap, ALTER TABLE .. SET TABLESPACE will
set the LSN and TLI while copying it, which is wrong, and heap_xlog_newpage()
will do the same thing during replay, so the corruption propagates to any
standby.  Note, however, that the bug can't be demonstrated unless archiving
is enabled, since in that case we skip WAL logging altogether, and the LSN/TLI
are not set.

Back-patch to 8.0; prior releases do not have tablespaces.

Analysis and patch by Jeff Davis.  Adjustments for back-branches and minor
wordsmithing by me.

13 years agoFix potential failure when hashing the output of a subplan that produces
Tom Lane [Wed, 28 Jul 2010 04:51:27 +0000 (04:51 +0000)]
Fix potential failure when hashing the output of a subplan that produces
a pass-by-reference datatype with a nontrivial projection step.
We were using the same memory context for the projection operation as for
the temporary context used by the hashtable routines in execGrouping.c.
However, the hashtable routines feel free to reset their temp context at
any time, which'd lead to destroying input data that was still needed.
Report and diagnosis by Tao Ma.

Back-patch to 8.1, where the problem was introduced by the changes that
allowed us to work with "virtual" tuples instead of materializing intermediate
tuple values everywhere.  The earlier code looks quite similar, but it doesn't
suffer the problem because the data gets copied into another context as a
result of having to materialize ExecProject's output tuple.

13 years agoSpelling fix
Peter Eisentraut [Tue, 27 Jul 2010 18:55:01 +0000 (18:55 +0000)]
Spelling fix

13 years agoFix grammar
Peter Eisentraut [Mon, 26 Jul 2010 20:30:07 +0000 (20:30 +0000)]
Fix grammar

backpatched to 8.1

13 years agoAvoid deep recursion when assigning XIDs to multiple levels of subxacts.
Robert Haas [Fri, 23 Jul 2010 00:43:44 +0000 (00:43 +0000)]
Avoid deep recursion when assigning XIDs to multiple levels of subxacts.

Backpatch to 8.0.

Andres Freund, with cleanup and adjustment for older branches by me.

13 years agoOops, in the previous fix to prevent a cursor that's being used in a FOR
Heikki Linnakangas [Tue, 13 Jul 2010 09:03:01 +0000 (09:03 +0000)]
Oops, in the previous fix to prevent a cursor that's being used in a FOR
loop from being dropped, I missed subtransaction cleanup. Pinned portals
must be dropped at subtransaction cleanup just as they are at main
transaction cleanup.

Per bug #5556 by Robert Walker. Backpatch to 8.0, 7.4 didn't have
subtransactions.

13 years agoAvoid an Assert failure in deconstruct_array() by making get_attstatsslot()
Tom Lane [Fri, 9 Jul 2010 22:58:12 +0000 (22:58 +0000)]
Avoid an Assert failure in deconstruct_array() by making get_attstatsslot()
use the actual element type of the array it's disassembling, rather than
trusting the type OID passed in by its caller.  This is needed because
sometimes the planner passes in a type OID that's only binary-compatible
with the target column's type, rather than being an exact match.  Per an
example from Bernd Helmle.

Possibly we should refactor get_attstatsslot/free_attstatsslot to not expect
the caller to supply type ID data at all, but for now I'll just do the
minimum-change fix.

Back-patch to 7.4.  Bernd's test case only crashes back to 8.0, but since
these subroutines are the same in 7.4, I suspect there may be variant
cases that would crash 7.4 as well.

13 years agoFix "cannot handle unplanned sub-select" error that can occur when a
Tom Lane [Thu, 8 Jul 2010 00:14:28 +0000 (00:14 +0000)]
Fix "cannot handle unplanned sub-select" error that can occur when a
sub-select contains a join alias reference that expands into an expression
containing another sub-select.  Per yesterday's report from Merlin Moncure
and subsequent off-list investigation.

Back-patch to 7.4.  Older versions didn't attempt to flatten sub-selects in
ways that would trigger this problem.

13 years agoThe previous fix in CVS HEAD and 8.4 for handling the case where a cursor
Heikki Linnakangas [Mon, 5 Jul 2010 09:27:42 +0000 (09:27 +0000)]
The previous fix in CVS HEAD and 8.4 for handling the case where a cursor
being used in a PL/pgSQL FOR loop is closed was inadequate, as Tom Lane
pointed out. The bug affects FOR statement variants too, because you can
close an implicitly created cursor too by guessing the "<unnamed portal X>"
name created for it.

To fix that, "pin" the portal to prevent it from being dropped while it's
being used in a PL/pgSQL FOR loop. Backpatch all the way to 7.4 which is
the oldest supported version.

13 years agoFix assorted misstatements and poor wording in the descriptions of the I/O
Tom Lane [Sat, 3 Jul 2010 04:03:33 +0000 (04:03 +0000)]
Fix assorted misstatements and poor wording in the descriptions of the I/O
formats for geometric types.  Per bug #5536 from Jon Strait, and my own
testing.

Back-patch to all supported branches, since this doco has been wrong right
along -- we certainly haven't changed the I/O behavior of these types in
many years.

13 years agoAllow ALTER TABLE .. SET TABLESPACE to be interrupted.
Robert Haas [Thu, 1 Jul 2010 14:11:03 +0000 (14:11 +0000)]
Allow ALTER TABLE .. SET TABLESPACE to be interrupted.

Backpatch to 8.0, where tablespaces were introduced.

Guillaume Lelarge

13 years agostringToNode() and deparse_expression_pretty() crash on invalid input,
Heikki Linnakangas [Wed, 30 Jun 2010 18:11:19 +0000 (18:11 +0000)]
stringToNode() and deparse_expression_pretty() crash on invalid input,
but we have nevertheless exposed them to users via pg_get_expr(). It would
be too much maintenance effort to rigorously check the input, so put a hack
in place instead to restrict pg_get_expr() so that the argument must come
from one of the system catalog columns known to contain valid expressions.

Per report from Rushabh Lathia. Backpatch to 7.4 which is the oldest
supported version at the moment.

13 years agoFix dblink_build_sql_insert() and related functions to handle dropped
Tom Lane [Tue, 15 Jun 2010 19:04:45 +0000 (19:04 +0000)]
Fix dblink_build_sql_insert() and related functions to handle dropped
columns correctly.  In passing, get rid of some dead logic in the
underlying get_sql_insert() etc functions --- there is no caller that
will pass null value-arrays to them.

Per bug report from Robert Voinea.

13 years agoConsolidate and improve checking of key-column-attnum arguments for
Tom Lane [Tue, 15 Jun 2010 16:22:45 +0000 (16:22 +0000)]
Consolidate and improve checking of key-column-attnum arguments for
dblink_build_sql_insert() and related functions.  In particular, be sure to
reject references to dropped and out-of-range column numbers.  The numbers
are still interpreted as physical column numbers, though, for backward
compatibility.

This patch replaces Joe's patch of 2010-02-03, which handled only some aspects
of the problem.

13 years agoRearrange dblink's dblink_build_sql_insert() and related routines to open and
Tom Lane [Mon, 14 Jun 2010 20:49:57 +0000 (20:49 +0000)]
Rearrange dblink's dblink_build_sql_insert() and related routines to open and
lock the target relation just once per SQL function call.  The original coding
obtained and released lock several times per call.  Aside from saving a
not-insignificant number of cycles, this eliminates possible race conditions
if someone tries to modify the relation's schema concurrently.  Also
centralize locking and permission-checking logic.

Problem noted while investigating a trouble report from Robert Voinea --- his
problem is still to be fixed, though.

13 years agoFix connection leak in dblink when dblink_connect() or dblink_connect_u()
Itagaki Takahiro [Wed, 9 Jun 2010 01:00:13 +0000 (01:00 +0000)]
Fix connection leak in dblink when dblink_connect() or dblink_connect_u()
end with "duplicate connection name" errors.

Backported to release 7.4.

13 years agoFix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Itagaki Takahiro [Thu, 3 Jun 2010 09:44:35 +0000 (09:44 +0000)]
Fix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Now long names are adjusted with truncate_identifier() and NOTICE messages
are raised if names are actually truncated.

Backported to release 8.0.

13 years agoChange ps_status.c to explicitly track the current logical length of ps_buffer.
Tom Lane [Thu, 27 May 2010 19:20:06 +0000 (19:20 +0000)]
Change ps_status.c to explicitly track the current logical length of ps_buffer.
This saves cycles in get_ps_display() on many popular platforms, and more
importantly ensures that get_ps_display() will correctly return an empty
string if init_ps_display() hasn't been called yet.  Per trouble report
from Ray Stell, in which log_line_prefix %i produced junk early in backend
startup.

Back-patch to 8.0.  7.4 doesn't have %i and its version of get_ps_display()
makes no pretense of avoiding pad junk anyhow.

14 years ago> Follow up a visit from the style police.
Andrew Dunstan [Mon, 17 May 2010 20:46:20 +0000 (20:46 +0000)]
> Follow up a visit from the style police.

14 years agoFix longstanding typo in V1 calling conventions documentation.
Robert Haas [Sun, 16 May 2010 03:56:03 +0000 (03:56 +0000)]
Fix longstanding typo in V1 calling conventions documentation.

Erik Rijkers

14 years agoImprove documentation of pg_restore's -l and -L switches to point out their
Tom Lane [Sat, 15 May 2010 18:11:30 +0000 (18:11 +0000)]
Improve documentation of pg_restore's -l and -L switches to point out their
interactions with filtering switches, such as -n and -t.  Per a complaint
from Russell Smith.

14 years agotag 8.1.21 REL8_1_21
Marc G. Fournier [Fri, 14 May 2010 03:35:26 +0000 (03:35 +0000)]
tag 8.1.21

14 years agoUpdate release notes with security issues.
Tom Lane [Thu, 13 May 2010 21:27:29 +0000 (21:27 +0000)]
Update release notes with security issues.

Security: CVE-2010-1169, CVE-2010-1170

14 years agoUse an entity instead of non-ASCII letter. Thom Brown
Tom Lane [Thu, 13 May 2010 19:16:38 +0000 (19:16 +0000)]
Use an entity instead of non-ASCII letter.  Thom Brown

14 years agoPrevent PL/Tcl from loading the "unknown" module from pltcl_modules unless
Tom Lane [Thu, 13 May 2010 18:29:37 +0000 (18:29 +0000)]
Prevent PL/Tcl from loading the "unknown" module from pltcl_modules unless
that is a regular table or view owned by a superuser.  This prevents a
trojan horse attack whereby any unprivileged SQL user could create such a
table and insert code into it that would then get executed in other users'
sessions whenever they call pltcl functions.

Worse yet, because the code was automatically loaded into both the "normal"
and "safe" interpreters at first use, the attacker could execute unrestricted
Tcl code in the "normal" interpreter without there being any pltclu functions
anywhere, or indeed anyone else using pltcl at all: installing pltcl is
sufficient to open the hole.  Change the initialization logic so that the
"unknown" code is only loaded into an interpreter when the interpreter is
first really used.  (That doesn't add any additional security in this
particular context, but it seems a prudent change, and anyway the former
behavior violated the principle of least astonishment.)

Security: CVE-2010-1170

14 years agoAbandon the use of Perl's Safe.pm to enforce restrictions in plperl, as it is
Andrew Dunstan [Thu, 13 May 2010 16:43:41 +0000 (16:43 +0000)]
Abandon the use of Perl's Safe.pm to enforce restrictions in plperl, as it is
fundamentally insecure. Instead apply an opmask to the whole interpreter that
imposes restrictions on unsafe operations. These restrictions are much harder
to subvert than is Safe.pm, since there is no container to be broken out of.
Backported to release 7.4.

In releases 7.4, 8.0 and 8.1 this also includes the necessary backporting of
the two interpreters model for plperl and plperlu adopted in release 8.2.

In versions 8.0 and up, the use of Perl's POSIX module to undo its locale
mangling on Windows has become insecure with these changes, so it is
replaced by our own routine, which is also faster.

Nice side effects of the changes include that it is now possible to use perl's
"strict" pragma in a natural way in plperl, and that perl's $a and
$b variables now work as expected in sort routines, and that function
compilation is significantly faster.

Tim Bunce and Andrew Dunstan, with reviews from Alex Hunsaker and
Alexey Klyukin.

Security: CVE-2010-1169

14 years agoTranslation update
Peter Eisentraut [Thu, 13 May 2010 07:22:03 +0000 (07:22 +0000)]
Translation update

14 years agoPreliminary release notes for releases 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25,
Tom Lane [Wed, 12 May 2010 23:27:51 +0000 (23:27 +0000)]
Preliminary release notes for releases 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25,
7.4.29.

14 years agoUpdate time zone data files to tzdata release 2010j: DST law changes in
Tom Lane [Tue, 11 May 2010 23:01:56 +0000 (23:01 +0000)]
Update time zone data files to tzdata release 2010j: DST law changes in
Argentina, Australian Antarctic, Bangladesh, Mexico, Morocco, Pakistan,
Palestine, Russia, Syria, Tunisia.  Historical corrections for Taiwan.

14 years agoWork around a subtle portability problem in use of printf %s format.
Tom Lane [Sat, 8 May 2010 16:40:38 +0000 (16:40 +0000)]
Work around a subtle portability problem in use of printf %s format.
Depending on which spec you read, field widths and precisions in %s may be
counted either in bytes or characters.  Our code was assuming bytes, which
is wrong at least for glibc's implementation, and in any case libc might
have a different idea of the prevailing encoding than we do.  Hence, for
portable results we must avoid using anything more complex than just "%s"
unless the string to be printed is known to be all-ASCII.

This patch fixes the cases I could find, including the psql formatting
failure reported by Hernan Gonzalez.  In HEAD only, I also added comments
to some places where it appears safe to continue using "%.*s".

14 years agoFix psql to not go into infinite recursion when expanding a variable that
Tom Lane [Wed, 5 May 2010 22:19:24 +0000 (22:19 +0000)]
Fix psql to not go into infinite recursion when expanding a variable that
refers to itself (directly or indirectly).  Instead, print a message when
recursion is detected, and don't expand the repeated reference.  Per bug
#5448 from Francis Markham.

Back-patch to 8.0.  Although the issue exists in 7.4 as well, it seems
impractical to fix there because of the lack of any state stack that
could be used to track active expansions.

14 years agoFix backpatching error in recent patch for ALTER USER f RESET ALL behavior.
Tom Lane [Wed, 5 May 2010 02:55:04 +0000 (02:55 +0000)]
Fix backpatching error in recent patch for ALTER USER f RESET ALL behavior.
The argument list for array_set() changed in 8.2 (in connection with allowing
nulls in arrays) but the newer argument list was used in the patches applied
to 8.1 and 8.0 branches.  The patch for 7.4 was OK though.  Per compiler
warnings.

14 years agoAdd code to InternalIpcMemoryCreate() to handle the case where shmget()
Tom Lane [Sat, 1 May 2010 22:47:00 +0000 (22:47 +0000)]
Add code to InternalIpcMemoryCreate() to handle the case where shmget()
returns EINVAL for an existing shared memory segment.  Although it's not
terribly sensible, that behavior does meet the POSIX spec because EINVAL
is the appropriate error code when the existing segment is smaller than the
requested size, and the spec explicitly disclaims any particular ordering of
error checks.  Moreover, it does in fact happen on OS X and probably other
BSD-derived kernels.  (We were able to talk NetBSD into changing their code,
but purging that behavior from the wild completely seems unlikely to happen.)
We need to distinguish collision with a pre-existing segment from invalid size
request in order to behave sensibly, so it's worth some extra code here to get
it right.  Per report from Gavin Kistner and subsequent investigation.

Back-patch to all supported versions, since any of them could get used
with a kernel having the debatable behavior.

14 years agoFix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
Tom Lane [Fri, 30 Apr 2010 19:16:10 +0000 (19:16 +0000)]
Fix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
memory if the result had zero rows, and also if there was any sort of error
while converting the result tuples into Python data.  Reported and partially
fixed by Andres Freund.

Back-patch to all supported versions.  Note: I haven't tested the 7.4 fix.
7.4's configure check for python is so obsolete it doesn't work on my
current machines :-(.  The logic change is pretty straightforward though.

14 years agoIP port -> TCP port
Peter Eisentraut [Thu, 15 Apr 2010 20:45:40 +0000 (20:45 +0000)]
IP port -> TCP port

backpatched to 8.1, where this first appeared

14 years agoSync perl's ppport.h on all branches back to 7.4 with recent update on HEAD, ensuring...
Andrew Dunstan [Sat, 3 Apr 2010 17:54:50 +0000 (17:54 +0000)]
Sync perl's ppport.h on all branches back to 7.4 with recent update on HEAD, ensuring we can build older branches with modern Perl installations.

14 years agoEnsure that contrib/pgstattuple functions respond to cancel interrupts
Tom Lane [Fri, 2 Apr 2010 16:17:18 +0000 (16:17 +0000)]
Ensure that contrib/pgstattuple functions respond to cancel interrupts
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara

14 years agoPrevent ALTER USER f RESET ALL from removing the settings that were put there
Alvaro Herrera [Thu, 25 Mar 2010 14:45:36 +0000 (14:45 +0000)]
Prevent ALTER USER f RESET ALL from removing the settings that were put there
by a superuser -- "ALTER USER f RESET setting" already disallows removing such a
setting.

Apply the same treatment to ALTER DATABASE d RESET ALL when run by a database
owner that's not superuser.

14 years agoClear error_context_stack and debug_query_string at the beginning of proc_exit,
Tom Lane [Sat, 20 Mar 2010 00:58:32 +0000 (00:58 +0000)]
Clear error_context_stack and debug_query_string at the beginning of proc_exit,
so that we won't try to attach any context printouts to messages that get
emitted while exiting.  Per report from Dennis Koegel, the context functions
won't necessarily work after we've started shutting down the backend, and it
seems possible that debug_query_string could be pointing at freed storage
as well.  The context information doesn't seem particularly relevant to
such messages anyway, so there's little lost by suppressing it.

Back-patch to all supported branches.  I can only demonstrate a crash with
log_disconnections messages back to 8.1, but the risk seems real in 8.0 and
before anyway.

14 years agoTypo fixes.
Magnus Hagander [Wed, 17 Mar 2010 18:04:14 +0000 (18:04 +0000)]
Typo fixes.

Fujii Masao

14 years agotag 8.1.20 REL8_1_20
Marc G. Fournier [Fri, 12 Mar 2010 03:51:21 +0000 (03:51 +0000)]
tag 8.1.20

14 years agoPreliminary release notes for releases 8.4.3, 8.3.10, 8.2.16, 8.1.20, 8.0.24,
Tom Lane [Wed, 10 Mar 2010 01:59:02 +0000 (01:59 +0000)]
Preliminary release notes for releases 8.4.3, 8.3.10, 8.2.16, 8.1.20, 8.0.24,
7.4.28.

14 years agoUse SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
Tom Lane [Tue, 9 Mar 2010 22:35:16 +0000 (22:35 +0000)]
Use SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
The latter is considered unwarranted chumminess with the implementation,
and can lead to crashes with recent Perl versions.

Report and fix by Tim Bunce.  Back-patch to all versions containing the
questionable coding pattern.

14 years agoUpdate time zone data files to tzdata release 2010d: DST law changes in Fiji,
Alvaro Herrera [Tue, 9 Mar 2010 14:31:32 +0000 (14:31 +0000)]
Update time zone data files to tzdata release 2010d: DST law changes in Fiji,
Samoa, Chile; corrections to recent changes in Paraguay and Bangladesh.

14 years agoAdd missing space in example.
Magnus Hagander [Mon, 8 Mar 2010 12:39:29 +0000 (12:39 +0000)]
Add missing space in example.

Tim Landscheidt

14 years agoUpdate time zone data files to tzdata release 2010c: DST law changes in
Tom Lane [Mon, 8 Mar 2010 01:18:45 +0000 (01:18 +0000)]
Update time zone data files to tzdata release 2010c: DST law changes in
Bangladesh, Mexico, Paraguay.

14 years agoWhen reading pg_hba.conf and similar files, do not treat @file as an inclusion
Tom Lane [Sat, 6 Mar 2010 00:46:13 +0000 (00:46 +0000)]
When reading pg_hba.conf and similar files, do not treat @file as an inclusion
unless (1) the @ isn't quoted and (2) the filename isn't empty.  This guards
against unexpectedly treating usernames or other strings in "flat files"
as inclusion requests, as seen in a recent trouble report from Ed L.
The empty-filename case would be guaranteed to misbehave anyway, because our
subsequent path-munging behavior results in trying to read the directory
containing the current input file.

I think this might finally explain the report at
http://archives.postgresql.org/pgsql-bugs/2004-05/msg00132.php
of a crash after printing "authentication file token too long, skipping",
since I was able to duplicate that message (though not a crash) on a
platform where stdio doesn't refuse to read directories.  We never got
far in investigating that problem, but now I'm suspicious that the trigger
condition was an @ in the flat password file.

Back-patch to all active branches since the problem can be demonstrated in all
branches except HEAD.  The test case, creating a user named "@", doesn't cause
a problem in HEAD since we got rid of the flat password file.  Nonetheless it
seems like a good idea to not consider quoted @ as a file inclusion spec,
so I changed HEAD too.

14 years agoFix a couple of places that would loop forever if attempts to read a stdio file
Tom Lane [Wed, 3 Mar 2010 20:31:34 +0000 (20:31 +0000)]
Fix a couple of places that would loop forever if attempts to read a stdio file
set ferror() but never set feof().  This is known to be the case for recent
glibc when trying to read a directory as a file, and might be true for other
platforms/cases too.  Per report from Ed L.  (There is more that we ought to
do about his report, but this is one easily identifiable issue.)

14 years agoMake contrib/xml2 use core xml.c's error handler, when available (that is,
Tom Lane [Wed, 3 Mar 2010 19:10:45 +0000 (19:10 +0000)]
Make contrib/xml2 use core xml.c's error handler, when available (that is,
in versions >= 8.3).  The core code is more robust and efficient than what
was there before, and this also reduces risks involved in swapping different
libxml error handler settings.

Before 8.3, there is still some risk of problems if add-on modules such as
Perl invoke libxml without setting their own error handler.  Given the lack
of reports I'm not sure there's a risk in practice, so I didn't take the
step of actually duplicating the core code into older contrib/xml2 branches.
Instead I just tweaked the existing code to ensure it didn't leave a dangling
pointer to short-lived memory when throwing an error.

14 years agoFix numericlocale psql option when used with a null string and latex and troff
Heikki Linnakangas [Mon, 1 Mar 2010 20:56:15 +0000 (20:56 +0000)]
Fix numericlocale psql option when used with a null string and latex and troff
formats; a null string must not be formatted as a numeric. The more exotic
formats latex and troff also incorrectly formatted all strings as numerics
when numericlocale was on.

Backpatch to 8.1 where numericlocale option was added.

This fixes bug #5355 reported by Andy Lester.

14 years agoFix contrib/xml2 so regression test still works when it's built without libxslt.
Tom Lane [Mon, 1 Mar 2010 18:08:34 +0000 (18:08 +0000)]
Fix contrib/xml2 so regression test still works when it's built without libxslt.

This involves modifying the module to have a stable ABI, that is, the
xslt_process() function still exists even without libxslt.  It throws a
runtime error if called, but doesn't prevent executing the CREATE FUNCTION
call.  This is a good thing anyway to simplify cross-version upgrades.