]> granicus.if.org Git - postgresql/log
postgresql
14 years agoSpelling fixes
Peter Eisentraut [Tue, 27 Jul 2010 18:56:22 +0000 (18:56 +0000)]
Spelling fixes

14 years agoFix grammar
Peter Eisentraut [Mon, 26 Jul 2010 20:29:09 +0000 (20:29 +0000)]
Fix grammar

backpatched to 8.1

14 years agoAvoid deep recursion when assigning XIDs to multiple levels of subxacts.
Robert Haas [Fri, 23 Jul 2010 00:43:17 +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.

14 years agoFix several problems in pg_dump's handling of SQL/MED objects, notably failure
Tom Lane [Wed, 14 Jul 2010 21:21:23 +0000 (21:21 +0000)]
Fix several problems in pg_dump's handling of SQL/MED objects, notably failure
to dump a PUBLIC user mapping correctly, as per bug #5560 from Shigeru Hanada.
Use the pg_user_mappings view rather than trying to access pg_user_mapping
directly, so that the code doesn't fail when run by a non-superuser.  And
clean up some minor carelessness such as unsafe usage of fmtId().

Back-patch to 8.4 where this code was added.

14 years agoAllow full SSL certificate verification (wherein libpq checks its host name
Tom Lane [Wed, 14 Jul 2010 17:10:03 +0000 (17:10 +0000)]
Allow full SSL certificate verification (wherein libpq checks its host name
parameter against server cert's CN field) to succeed in the case where
both host and hostaddr are specified.  As with the existing precedents
for Kerberos, GSSAPI, SSPI, it is the calling application's responsibility
that host and hostaddr match up --- we just use the host name as given.
Per bug #5559 from Christopher Head.

In passing, make the error handling and messages for the no-host-name-given
failure more consistent among these four cases, and correct a lie in the
documentation: we don't attempt to reverse-lookup host from hostaddr
if host is missing.

Back-patch to 8.4 where SSL cert verification was introduced.

15 years agoOops, in the previous fix to prevent a cursor that's being used in a FOR
Heikki Linnakangas [Tue, 13 Jul 2010 09:02:40 +0000 (09:02 +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.

15 years agoAvoid an Assert failure in deconstruct_array() by making get_attstatsslot()
Tom Lane [Fri, 9 Jul 2010 22:57:54 +0000 (22:57 +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.

15 years agoFix "cannot handle unplanned sub-select" error that can occur when a
Tom Lane [Thu, 8 Jul 2010 00:14:10 +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.

15 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:24 +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.

15 years agoAllow REASSIGNED OWNED to handle opclasses and opfamilies.
Robert Haas [Sat, 3 Jul 2010 13:53:26 +0000 (13:53 +0000)]
Allow REASSIGNED OWNED to handle opclasses and opfamilies.

Backpatch to 8.3, which is as far back as we have opfamilies.
The opclass portion could probably be backpatched to 8.2, when
REASSIGN OWNED was added, but for now I have not done that.

Asko Tiidumaa, with minor adjustments by me.

15 years agoFix assorted misstatements and poor wording in the descriptions of the I/O
Tom Lane [Sat, 3 Jul 2010 04:03:14 +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.

15 years agoUnbreak MSVC builds by removing copydir.c from list of libpgport files
Andrew Dunstan [Sat, 3 Jul 2010 00:58:23 +0000 (00:58 +0000)]
Unbreak MSVC builds by removing copydir.c from list of libpgport files

15 years agoMove copydir.c from src/port to src/backend/storage/file
Robert Haas [Fri, 2 Jul 2010 17:03:38 +0000 (17:03 +0000)]
Move copydir.c from src/port to src/backend/storage/file

The previous commit to make copydir() interruptible prevented
postgres.exe from linking on MinGW and Cygwin, because on those
platforms libpgport_srv.a can't freely reference symbols defined
by the backend.  Since that code is already backend-specific anyway,
just move the whole file into the backend rather than adding further
kludges to deal with the symbols needed by CHECK_FOR_INTERRUPTS().

This probably needs some further cleanup, but this commit just moves
the file as-is, which should hopefully be enough to turn the
buildfarm green again.

15 years agoAllow copydir() to be interrupted.
Robert Haas [Thu, 1 Jul 2010 20:13:06 +0000 (20:13 +0000)]
Allow copydir() to be interrupted.

This makes ALTER DATABASE .. SET TABLESPACE and CREATE DATABASE more
sensitive to interrupts.  Backpatch to 8.4, where ALTER DATABASE .. SET
TABLESPACE was introduced.  We could go back further, but in the absence
of complaints about the CREATE DATABASE case it doesn't seem worth it.

Guillaume Lelarge, with a small correction by me.

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

Backpatch to 8.0, where tablespaces were introduced.

Guillaume Lelarge

15 years agostringToNode() and deparse_expression_pretty() crash on invalid input,
Heikki Linnakangas [Wed, 30 Jun 2010 18:10:37 +0000 (18:10 +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.

15 years agoImprove pg_dump's checkSeek() function to verify the functioning of ftello
Tom Lane [Mon, 28 Jun 2010 02:07:09 +0000 (02:07 +0000)]
Improve pg_dump's checkSeek() function to verify the functioning of ftello
as well as fseeko, and to not assume that fseeko(fp, 0, SEEK_CUR) proves
anything.  Also improve some related comments.  Per my observation that
the SEEK_CUR test didn't actually work on some platforms, and subsequent
discussion with Robert Haas.

Back-patch to 8.4.  In earlier releases it's not that important whether
we get the hasSeek test right, but with parallel restore it matters.

15 years agoFix pg_restore so parallel restore doesn't fail when the input file doesn't
Tom Lane [Sun, 27 Jun 2010 19:07:30 +0000 (19:07 +0000)]
Fix pg_restore so parallel restore doesn't fail when the input file doesn't
contain data offsets (which it won't, if pg_dump thought its output wasn't
seekable).  To do that, remove an unnecessarily aggressive error check, and
instead fail if we get to the end of the archive without finding the desired
data item.  Also improve the error message to be more specific about the
cause of the problem.  Per discussion of recent report from Igor Neyman.

Back-patch to 8.4 where parallel restore was introduced.

15 years agoDeprecate the use of => as an operator name.
Robert Haas [Tue, 22 Jun 2010 11:36:28 +0000 (11:36 +0000)]
Deprecate the use of => as an operator name.

In HEAD, emit a warning when an operator named => is defined.
In both HEAD and the backbranches (except in 8.2, where contrib
modules do not have documentation), document that hstore's text =>
text operator may be removed in a future release, and encourage the
use of the hstore(text, text) function instead.  This function only
exists in HEAD (previously, it was called tconvert), so backpatch
it back to 8.2, when hstore was added.  Per discussion.

15 years agoIn a PL/pgSQL "FOR cursor" statement, the statements executed in the loop
Heikki Linnakangas [Mon, 21 Jun 2010 09:49:58 +0000 (09:49 +0000)]
In a PL/pgSQL "FOR cursor" statement, the statements executed in the loop
might close the cursor,  rendering the Portal pointer to it invalid.
Closing the cursor in the middle of the loop is not a very sensible thing
to do, but we must handle it gracefully and throw an error instead of
crashing.

15 years agoFix mishandling of whole-row Vars referencing a view or sub-select.
Tom Lane [Mon, 21 Jun 2010 00:14:54 +0000 (00:14 +0000)]
Fix mishandling of whole-row Vars referencing a view or sub-select.
If such a Var appeared within a nested sub-select, we failed to translate it
correctly during pullup of the view, because the recursive call to
replace_rte_variables_mutator was looking for the wrong sublevels_up value.
Bug was introduced during the addition of the PlaceHolderVar mechanism.
Per bug #5514 from Marcos Castedo.

15 years agoFix typo, init => int, per KOIZUMI Satoru.
Tom Lane [Thu, 17 Jun 2010 16:03:36 +0000 (16:03 +0000)]
Fix typo, init => int, per KOIZUMI Satoru.

15 years agoFix dblink_build_sql_insert() and related functions to handle dropped
Tom Lane [Tue, 15 Jun 2010 19:04:22 +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.

15 years agoConsolidate and improve checking of key-column-attnum arguments for
Tom Lane [Tue, 15 Jun 2010 16:22:26 +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.

15 years agoRearrange dblink's dblink_build_sql_insert() and related routines to open and
Tom Lane [Mon, 14 Jun 2010 20:49:39 +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.

15 years agoAdd index entry for ::, per complaint from John Gage.
Alvaro Herrera [Wed, 9 Jun 2010 16:43:52 +0000 (16:43 +0000)]
Add index entry for ::, per complaint from John Gage.

15 years agoMake the walwriter close it's handle to an old xlog segment if it's no longer
Magnus Hagander [Wed, 9 Jun 2010 10:54:53 +0000 (10:54 +0000)]
Make the walwriter close it's handle to an old xlog segment if it's no longer
the current one. Not doing this would leave the walwriter with a handle to a
deleted file if there was nothing for it to do for a long period of time,
preventing the file from  being completely removed.

Reported by Tollef Fog Heen, and thanks to Heikki for some hand-holding with
the patch.

15 years agoAvoid "identifier will be truncated" warning in dblink
Itagaki Takahiro [Wed, 9 Jun 2010 03:40:16 +0000 (03:40 +0000)]
Avoid "identifier will be truncated" warning in dblink
when connection string is longer than NAMEDATALEN.
The previous fix for long connection name broke the behavior.

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

Backported to release 7.4.

15 years agoAdd missed function dblink_connect_u(text[,text]) to uninstall script
Teodor Sigaev [Mon, 7 Jun 2010 15:14:50 +0000 (15:14 +0000)]
Add missed function dblink_connect_u(text[,text]) to uninstall script

15 years agoEnsure default-only storage parameters for TOAST relations
Itagaki Takahiro [Mon, 7 Jun 2010 03:01:35 +0000 (03:01 +0000)]
Ensure default-only storage parameters for TOAST relations
to be initialized with proper values. Affected parameters are
fillfactor, analyze_threshold, and analyze_scale_factor.

Especially uninitialized fillfactor caused inefficient page usage
because we built a StdRdOptions struct in which fillfactor is zero
if any reloption is set for the toast table.

In addition, we disallow toast.autovacuum_analyze_threshold and
toast.autovacuum_analyze_scale_factor because we didn't actually
support them; they are always ignored.

Report by Rumko on pgsql-bugs on 12 May 2010.
Analysis by Tom Lane and Alvaro Herrera. Patch by me.

Backpatch to 8.4.

15 years agoData returned by RETURNING clause wasn't correctly processed by ecpg. Patch backporte...
Michael Meskes [Fri, 4 Jun 2010 10:48:05 +0000 (10:48 +0000)]
Data returned by RETURNING clause wasn't correctly processed by ecpg. Patch backported from HEAD.

15 years agoFix regression test name for plperlu_plperl in msvc.
Andrew Dunstan [Thu, 3 Jun 2010 11:03:09 +0000 (11:03 +0000)]
Fix regression test name for plperlu_plperl in msvc.

15 years agoFix dblink to treat connection names longer than NAMEDATALEN-2 (62 bytes).
Itagaki Takahiro [Thu, 3 Jun 2010 09:40:17 +0000 (09:40 +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.

15 years agoRun recently backported plperlu_plperl regression tests when building with MSVC on...
Andrew Dunstan [Wed, 2 Jun 2010 15:58:26 +0000 (15:58 +0000)]
Run recently backported plperlu_plperl regression tests when building with MSVC on releases 8.4 and 8.3. Regression tests weren't supported before that.

15 years agoFix misuse of Lossy Counting (LC) algorithm in compute_tsvector_stats().
Tom Lane [Sun, 30 May 2010 21:59:09 +0000 (21:59 +0000)]
Fix misuse of Lossy Counting (LC) algorithm in compute_tsvector_stats().

We must filter out hashtable entries with frequencies less than those
specified by the algorithm, else we risk emitting junk entries whose
actual frequency is much less than other lexemes that did not get
tabulated.  This is bad enough by itself, but even worse is that
tsquerysel() believes that the minimum frequency seen in pg_statistic is a
hard upper bound for lexemes not included, and was thus underestimating
the frequency of non-MCEs.

Also, set the threshold frequency to something with a little bit of theory
behind it, to wit assume that the input distribution is approximately
Zipfian.  This might need adjustment in future, but some preliminary
experiments suggest that it's not too unreasonable.

Back-patch to 8.4, where this code was introduced.

Jan Urbanski, with some editorialization by Tom

15 years agoRewrite LIKE's %-followed-by-_ optimization so it really works (this time
Tom Lane [Fri, 28 May 2010 17:35:30 +0000 (17:35 +0000)]
Rewrite LIKE's %-followed-by-_ optimization so it really works (this time
for sure ;-)).  It now also optimizes more cases, such as %_%_.  Improve
comments too.  Per bug #5478.

In passing, also rename the TCHAR macro to GETCHAR, because pgindent is
messing with the formatting of the former (apparently it now thinks TCHAR
is a typedef name).

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

15 years agoRejigger mergejoin logic so that a tuple with a null in the first merge column
Tom Lane [Fri, 28 May 2010 01:14:11 +0000 (01:14 +0000)]
Rejigger mergejoin logic so that a tuple with a null in the first merge column
is treated like end-of-input, if nulls sort last in that column and we are not
doing outer-join filling for that input.  In such a case, the tuple cannot
join to anything from the other input (because we assume mergejoinable
operators are strict), and neither can any tuple following it in the sort
order.  If we're not interested in doing outer-join filling we can just
pretend the tuple and its successors aren't there at all.  This can save a
great deal of time in situations where there are many nulls in the join
column, as in a recent example from Scott Marlowe.  Also, since the planner
tends to not count nulls in its mergejoin scan selectivity estimates, this
is an important fix to make the runtime behavior more like the estimate.

I regard this as an omission in the patch I wrote years ago to teach mergejoin
that tuples containing nulls aren't joinable, so I'm back-patching it.  But
only to 8.3 --- in older versions, we didn't have a solid notion of whether
nulls sort high or low, so attempting to apply this optimization could break
things.

15 years agoChange ps_status.c to explicitly track the current logical length of ps_buffer.
Tom Lane [Thu, 27 May 2010 19:19:44 +0000 (19:19 +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.

15 years agoMake CREATE INDEX run expression preprocessing on a proposed index expression
Tom Lane [Thu, 27 May 2010 15:59:15 +0000 (15:59 +0000)]
Make CREATE INDEX run expression preprocessing on a proposed index expression
before it checks whether the expression is immutable.  This covers two cases
that were previously handled poorly:

1. SQL function inlining could reduce the apparent volatility of the
expression, allowing an expression to be accepted where it previously would
not have been.  As an example, polymorphic functions must be marked with the
worst-case volatility they have for any argument type, but for specific
argument types they might not be so volatile, so indexing could be allowed.
(Since the planner will refuse to inline functions in cases where the
apparent volatility of the expression would increase, this won't break
any cases that were accepted before.)

2. A nominally immutable function could have default arguments that are
volatile expressions.  In such a case insertion of the defaults will increase
both the apparent and actual volatility of the expression, so it is
*necessary* to check this before allowing the expression to be indexed.

Back-patch to 8.4, where default arguments were introduced.

15 years agoFix oversight in construction of sort/unique plans for UniquePaths.
Tom Lane [Tue, 25 May 2010 17:44:47 +0000 (17:44 +0000)]
Fix oversight in construction of sort/unique plans for UniquePaths.
If the original IN operator is cross-type, for example int8 = int4,
we need to use int4 < int4 to sort the inner data and int4 = int4
to unique-ify it.  We got the first part of that right, but tried to
use the original IN operator for the equality checks.  Per bug #5472
from Vlad Romascanu.

Backpatch to 8.4, where the bug was introduced by the patch that unified
SortClause and GroupClause.  I was able to take out a whole lot of on-the-fly
calls of get_equality_op_for_ordering_op(), but failed to realize that
I needed to put one back in right here :-(

15 years agoChange the "N. Central Asia Standard Time" timezone to map to
Magnus Hagander [Thu, 20 May 2010 14:13:23 +0000 (14:13 +0000)]
Change the "N. Central Asia Standard Time" timezone to map to
Asia/Novosibirsk on Windows.

Microsoft changed the behaviour of this zone in the timezone update
from KB976098. The zones differ in handling of DST, and the old
zone was just removed.

Noted by Dmitry Funk

15 years agoRefer to pg_ident.conf as config file for username mapping, as it's
Magnus Hagander [Tue, 18 May 2010 19:05:24 +0000 (19:05 +0000)]
Refer to pg_ident.conf as config file for username mapping, as it's
now used for other things than just ident authentication.

Noted by Stephen Frost

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

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

Erik Rijkers

15 years agoImprove documentation of pg_restore's -l and -L switches to point out their
Tom Lane [Sat, 15 May 2010 18:11:13 +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.

15 years agoFix typos in comments, spotted by Josh Kupershmidt.
Heikki Linnakangas [Sat, 15 May 2010 09:32:03 +0000 (09:32 +0000)]
Fix typos in comments, spotted by Josh Kupershmidt.

15 years agotag 8.4.4 REL8_4_4
Marc G. Fournier [Fri, 14 May 2010 03:20:06 +0000 (03:20 +0000)]
tag 8.4.4

15 years agoFix MSVC builds for recent plperl changes. Go back to version 8.2, which is
Andrew Dunstan [Thu, 13 May 2010 21:33:55 +0000 (21:33 +0000)]
Fix MSVC builds for recent plperl changes. Go back to version 8.2, which is
where we started supporting MSVC builds.

Security: CVE-2010-1169

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

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

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

15 years agoUse "TOAST table" in place of the vague, not-used-elsewhere phrase
Tom Lane [Thu, 13 May 2010 18:54:23 +0000 (18:54 +0000)]
Use "TOAST table" in place of the vague, not-used-elsewhere phrase
"supplementary storage table".

15 years agoPrevent PL/Tcl from loading the "unknown" module from pltcl_modules unless
Tom Lane [Thu, 13 May 2010 18:29:19 +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

15 years agoAbandon the use of Perl's Safe.pm to enforce restrictions in plperl, as it is
Andrew Dunstan [Thu, 13 May 2010 16:40:36 +0000 (16:40 +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

15 years agoFix some spelling errors.
Magnus Hagander [Thu, 13 May 2010 14:16:58 +0000 (14:16 +0000)]
Fix some spelling errors.

Thom Brown

15 years agoTranslation update
Peter Eisentraut [Thu, 13 May 2010 10:50:20 +0000 (10:50 +0000)]
Translation update

15 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:26 +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.

15 years agoUpdate time zone data files to tzdata release 2010j: DST law changes in
Tom Lane [Tue, 11 May 2010 23:01:33 +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.

15 years agoAdd PKST to the default set of timezone abbreviations.
Tom Lane [Tue, 11 May 2010 22:36:58 +0000 (22:36 +0000)]
Add PKST to the default set of timezone abbreviations.
Per discussion, if we have PKT in there then PKST should be too.
Also, fix mistaken claim that these abbrevs are not known to zic.

15 years agoCause the archiver process to adopt new postgresql.conf settings (particularly
Tom Lane [Tue, 11 May 2010 16:42:33 +0000 (16:42 +0000)]
Cause the archiver process to adopt new postgresql.conf settings (particularly
archive_command) as soon as possible, namely just before issuing a new call
of archive_command, even when there is a backlog of files to be archived.
The original coding would only absorb new settings after clearing the backlog
and returning to the outer loop.  Per discussion.

Back-patch to 8.3.  The logic in prior versions is a bit different and it
doesn't seem worth taking any risks of breaking it.

15 years agoSet per-function GUC settings during validating the function.
Itagaki Takahiro [Tue, 11 May 2010 04:56:37 +0000 (04:56 +0000)]
Set per-function GUC settings during validating the function.
Now validators work properly even when the settings contain
parameters that affect behavior of the function, like search_path.

Reported by Erwin Brandstetter.

15 years agoSuppress signed-vs-unsigned-char warning.
Tom Lane [Sun, 9 May 2010 18:17:52 +0000 (18:17 +0000)]
Suppress signed-vs-unsigned-char warning.

15 years agoWork around a subtle portability problem in use of printf %s format.
Tom Lane [Sat, 8 May 2010 16:40:03 +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".

15 years agoECPG connect routine only checked for NULL to find empty parameters, but user and...
Michael Meskes [Fri, 7 May 2010 19:38:17 +0000 (19:38 +0000)]
ECPG connect routine only checked for NULL to find empty parameters, but user and password can also be "".

15 years agoFix psql to not go into infinite recursion when expanding a variable that
Tom Lane [Wed, 5 May 2010 22:19:05 +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.

15 years agoFix incorrect parameter tag in docs, spotted by KOIZUMI Satoru.
Heikki Linnakangas [Wed, 5 May 2010 15:13:25 +0000 (15:13 +0000)]
Fix incorrect parameter tag in docs, spotted by KOIZUMI Satoru.

15 years agoFix replay of XLOG_HEAP_NEWPAGE WAL records to pay attention to the forknum
Tom Lane [Sun, 2 May 2010 22:28:11 +0000 (22:28 +0000)]
Fix replay of XLOG_HEAP_NEWPAGE WAL records to pay attention to the forknum
field of the WAL record.  The previous coding always wrote to the main fork,
resulting in data corruption if the page was meant to go into a non-default
fork.

At present, the only operation that can produce such WAL records is
ALTER TABLE/INDEX SET TABLESPACE when executed with archive_mode = on.
Data corruption would be observed on standby slaves, and could occur on the
master as well if a database crash and recovery occurred after committing
the ALTER and before the next checkpoint.  Per report from Gordon Shannon.

Back-patch to 8.4; the problem doesn't exist in earlier branches because
we didn't have a concept of multiple relation forks then.

15 years agoAdd code to InternalIpcMemoryCreate() to handle the case where shmget()
Tom Lane [Sat, 1 May 2010 22:46:36 +0000 (22:46 +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.

15 years agoFix multiple memory leaks in PLy_spi_execute_fetch_result: it would leak
Tom Lane [Fri, 30 Apr 2010 19:15:51 +0000 (19:15 +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.

15 years agoProvide better guidance for adjusting shared_buffers.
Robert Haas [Sun, 18 Apr 2010 23:59:55 +0000 (23:59 +0000)]
Provide better guidance for adjusting shared_buffers.

This change was previously committed to HEAD, but the consensus seems to be
in favor of back-patching it.  I'm only backpatching as far as 8.3.X, however,
because it's not clear to me to what degree this advice applies to older
branches, and in any case our first advice to anyone attempting to tune those
versions is likely to be "upgrade".

15 years agoOn Windows, syslogger runs in two threads. The main thread processes config
Heikki Linnakangas [Fri, 16 Apr 2010 09:51:54 +0000 (09:51 +0000)]
On Windows, syslogger runs in two threads. The main thread processes config
reload and rotation signals, and a helper thread reads messages from the
pipe and writes them to the log file. However, server code isn't generally
thread-safe, so if both try to do e.g palloc()/pfree() at the same time,
bad things will happen. To fix that, use a critical section (which is like
a mutex) to enforce that only one the threads are active at a time.

15 years agoFix psql's \copy to not insert spaces around dots and commas in the text of
Tom Lane [Thu, 15 Apr 2010 21:05:11 +0000 (21:05 +0000)]
Fix psql's \copy to not insert spaces around dots and commas in the text of
the SELECT query in \copy (SELECT ...) commands.  This is unnecessary and
breaks numeric literals, as seen in bug #5411 from Vitalii Tymchyshyn.

This change has already been made in passing in HEAD; backpatch to 8.2
through 8.4 (earlier releases don't have COPY (SELECT ...) at all).

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

backpatched to 8.1, where this first appeared

15 years agoFix plpgsql's exec_eval_expr() to ensure it returns a sane type OID
Tom Lane [Wed, 14 Apr 2010 23:52:16 +0000 (23:52 +0000)]
Fix plpgsql's exec_eval_expr() to ensure it returns a sane type OID
even when the expression is a query that returns no rows.

So far as I can tell, the only caller that actually fails when a garbage
OID is returned is exec_stmt_case(), which is new in 8.4 --- in all other
cases, we might make a useless trip through casting logic, but we won't
fail since the isnull flag will be set.  Hence, backpatch only to 8.4,
just in case there are apps out there that aren't expecting an error to
be thrown if the query returns more or less than one column.  (Which seems
unlikely, since the error would be thrown if the query ever did return a
row; but it's possible there's some never-exercised code out there.)

Per report from Mario Splivalo.

15 years agoFix a problem introduced by my patch of 2010-01-12 that revised the way
Tom Lane [Wed, 14 Apr 2010 21:31:20 +0000 (21:31 +0000)]
Fix a problem introduced by my patch of 2010-01-12 that revised the way
relcache reload works.  In the patched code, a relcache entry in process of
being rebuilt doesn't get unhooked from the relcache hash table; which means
that if a cache flush occurs due to sinval queue overrun while we're
rebuilding it, the entry could get blown away by RelationCacheInvalidate,
resulting in crash or misbehavior.  Fix by ensuring that an entry being
rebuilt has positive refcount, so it won't be seen as a target for removal
if a cache flush occurs.  (This will mean that the entry gets rebuilt twice
in such a scenario, but that's okay.)  It appears that the problem can only
arise within a transaction that has previously reassigned the relfilenode of
a pre-existing table, via TRUNCATE or a similar operation.  Per bug #5412
from Rusty Conover.

Back-patch to 8.2, same as the patch that introduced the problem.
I think that the failure can't actually occur in 8.2, since it lacks the
rd_newRelfilenodeSubid optimization, but let's make it work like the later
branches anyway.

Patch by Heikki, slightly editorialized on by me.

15 years agoClean up inconsistent commas
Magnus Hagander [Fri, 9 Apr 2010 11:50:03 +0000 (11:50 +0000)]
Clean up inconsistent commas

15 years agoUpdate list of Windows timezones we try to match localized names against
Magnus Hagander [Fri, 9 Apr 2010 11:46:12 +0000 (11:46 +0000)]
Update list of Windows timezones we try to match localized names against
to one that's up to date with Windows 2003R2.

15 years agoProceed to look for the next timezone when matching a localized
Magnus Hagander [Thu, 8 Apr 2010 11:26:06 +0000 (11:26 +0000)]
Proceed to look for the next timezone when matching a localized
Windows timezone name where the information in the registry is
incomplete, instead of aborting.

This fixes cases when the registry information is incomplete for
a timezone that is alphabetically before the one that is in use.

Per report from Alexander Forschner

15 years agoLog the actual timezone name that we fail to look up the values for in
Magnus Hagander [Tue, 6 Apr 2010 20:35:17 +0000 (20:35 +0000)]
Log the actual timezone name that we fail to look up the values for in
case the registry data doesn't follow the format we expect, to facilitate
debugging.

15 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:53:55 +0000 (17:53 +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.

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

Tatsuhito Kasahara

15 years agoDon't pass an invalid file handle to dup2(). That causes a crash on
Heikki Linnakangas [Thu, 1 Apr 2010 20:12:28 +0000 (20:12 +0000)]
Don't pass an invalid file handle to dup2(). That causes a crash on
Windows, thanks to a feature in CRT called Parameter Validation.

Backpatch to 8.2, which is the oldest version supported on Windows. In
8.2 and 8.3 also backpatch the earlier change to use DEVNULL instead of
NULL_DEV #define for a /dev/null-like device. NULL_DEV was hard-coded to
"/dev/null" regardless of platform, which didn't work on Windows, while
DEVNULL works on all platforms. Restarting syslogger didn't work on
Windows on versions 8.3 and below because of that.

15 years agoFix "constraint_exclusion = partition" logic so that it will also attempt
Tom Lane [Tue, 30 Mar 2010 21:58:18 +0000 (21:58 +0000)]
Fix "constraint_exclusion = partition" logic so that it will also attempt
constraint exclusion on an inheritance set that is the target of an UPDATE
or DELETE query.  Per gripe from Marc Cousin.  Back-patch to 8.4 where
the feature was introduced.

15 years agoFix ginint4_queryextract() to actually do what it was intended to do for an
Tom Lane [Thu, 25 Mar 2010 15:50:15 +0000 (15:50 +0000)]
Fix ginint4_queryextract() to actually do what it was intended to do for an
unsatisfiable query, such as indexcol && empty_array.  It should return -1
to tell GIN no scan is required; but silly typo disabled the logic for that,
resulting in unnecessary "GIN indexes do not support whole-index scans" error.
Per bug report from Jeff Trout.

Back-patch to 8.3 where the logic was introduced.

15 years agoPrevent ALTER USER f RESET ALL from removing the settings that were put there
Alvaro Herrera [Thu, 25 Mar 2010 14:44:51 +0000 (14:44 +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.

15 years agoFix thinko in log message for "sameuser" ident map mismatch: the provided
Tom Lane [Wed, 24 Mar 2010 17:05:51 +0000 (17:05 +0000)]
Fix thinko in log message for "sameuser" ident map mismatch: the provided
and authenticated usernames were swapped.  Reported by Bryan Henderson
in bug #5386.

Also clean up poorly-maintained header comment for this function.

15 years agoClear error_context_stack and debug_query_string at the beginning of proc_exit,
Tom Lane [Sat, 20 Mar 2010 00:58:14 +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.

15 years agoModify error context callback functions to not assume that they can fetch
Tom Lane [Fri, 19 Mar 2010 22:54:49 +0000 (22:54 +0000)]
Modify error context callback functions to not assume that they can fetch
catalog entries via SearchSysCache and related operations.  Although, at the
time that these callbacks are called by elog.c, we have not officially aborted
the current transaction, it still seems rather risky to initiate any new
catalog fetches.  In all these cases the needed information is readily
available in the caller and so it's just a matter of a bit of extra notation
to pass it to the callback.

Per crash report from Dennis Koegel.  I've concluded that the real fix for
his problem is to clear the error context stack at entry to proc_exit, but
it still seems like a good idea to make the callbacks a bit less fragile
for other cases.

Backpatch to 8.4.  We could go further back, but the patch doesn't apply
cleanly.  In the absence of proof that this fixes something and isn't just
paranoia, I'm not going to expend the effort.

15 years agoFix missing parentheses for current_query(), per bug #5378.
Tom Lane [Thu, 18 Mar 2010 15:29:51 +0000 (15:29 +0000)]
Fix missing parentheses for current_query(), per bug #5378.
Also make a couple other minor editorial improvements.

15 years agoFix bug in %r handling in recovery_end_command, it always came out as 0
Heikki Linnakangas [Thu, 18 Mar 2010 09:18:54 +0000 (09:18 +0000)]
Fix bug in %r handling in recovery_end_command, it always came out as 0
because InRedo was cleared before recovery_end_command was executed.
Also, always take ControlFileLock when reading checkpoint location for
%r. That didn't matter before, but in 8.4 bgwriter is active during
recovery and can modify the control file concurrently.

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

Fujii Masao

15 years agoFix incorrect example in CREATE INDEX reference page, per Josh Kupershmidt.
Tom Lane [Wed, 17 Mar 2010 15:55:55 +0000 (15:55 +0000)]
Fix incorrect example in CREATE INDEX reference page, per Josh Kupershmidt.
Also fix and uncomment an old example of creating a GIST index, and make
a couple of other minor editorial adjustments.

15 years agotag 8.4.3 REL8_4_3
Marc G. Fournier [Fri, 12 Mar 2010 03:23:23 +0000 (03:23 +0000)]
tag 8.4.3

15 years agoImprove PL/Perl documentation of database access functions. (Backpatch to 8.4
Alvaro Herrera [Thu, 11 Mar 2010 21:53:53 +0000 (21:53 +0000)]
Improve PL/Perl documentation of database access functions.  (Backpatch to 8.4
of a patch previously applied by Bruce Momjian to CVS HEAD)

Alexey Klyukin

15 years agoAdd missing reset of need_initialization in reloptions code.
Tom Lane [Thu, 11 Mar 2010 21:47:25 +0000 (21:47 +0000)]
Add missing reset of need_initialization in reloptions code.

This resulted in useless extra work during every call of parseRelOptions,
but no bad effects other than that.  Noted by Alvaro.

15 years agoSync timezone code with tzcode 2010c from the Olson group. This fixes some
Tom Lane [Thu, 11 Mar 2010 18:43:32 +0000 (18:43 +0000)]
Sync timezone code with tzcode 2010c from the Olson group.  This fixes some
corner cases that come up in certain timezones (apparently, only those with
lots and lots of distinct TZ transition rules, as far as I can gather from
a quick scan of their archives).  Per suggestion from Jeevan Chalke.

Back-patch to 8.4.  Possibly we need to push this into earlier releases
as well, but I'm hesitant to update them to the 64-bit tzcode without
more thought and testing.

15 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:58:24 +0000 (01:58 +0000)]
Preliminary release notes for releases 8.4.3, 8.3.10, 8.2.16, 8.1.20, 8.0.24,
7.4.28.

15 years agoUse SvROK(sv) rather than directly checking SvTYPE(sv) == SVt_RV in plperl.
Tom Lane [Tue, 9 Mar 2010 22:34:49 +0000 (22:34 +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.

15 years agoUpdate time zone data files to tzdata release 2010d: DST law changes in Fiji,
Alvaro Herrera [Tue, 9 Mar 2010 14:28:46 +0000 (14:28 +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.

15 years agoReturn proper exit code (3) from psql when ON_ERROR_STOP=on and
Bruce Momjian [Tue, 9 Mar 2010 01:10:23 +0000 (01:10 +0000)]
Return proper exit code (3) from psql when ON_ERROR_STOP=on and
--single-transaction are both used and the failure happens in commit,
e.g. failed deferred trigger.  Also properly free BEGIN/COMMIT result
structures from --single-transaction.

Per report from Dominic Bevacqua