Tom Lane [Mon, 11 Oct 2010 23:04:59 +0000 (19:04 -0400)]
Fix assorted bugs in GIN's WAL replay logic.
The original coding was quite sloppy about handling the case where
XLogReadBuffer fails (because the page has since been deleted). This
would result in either "bad buffer id: 0" or an Assert failure during
replay, if indeed the page were no longer there. In a couple of places
it also neglected to check whether the change had already been applied,
which would probably result in corrupted index contents. I believe that
bug #5703 is an instance of the first problem. These issues could show up
without replication, but only if you were unfortunate enough to crash
between modification of a GIN index and the next checkpoint.
Back-patch to 8.2, which is as far back as GIN has WAL support.
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.
Robert Haas [Thu, 7 Oct 2010 16:19:03 +0000 (12:19 -0400)]
Improve WAL reliability documentation, and add more cross-references to it.
In particular, we are now more explicit about the fact that you may need
wal_sync_method=fsync_writethrough for crash-safety on some platforms,
including MaxOS X. There's also now an explicit caution against assuming
that the default setting of wal_sync_method is either crash-safe or best
for performance.
Tom Lane [Sun, 3 Oct 2010 00:02:46 +0000 (20:02 -0400)]
Behave correctly if INSERT ... VALUES is decorated with additional clauses.
In versions 8.2 and up, the grammar allows attaching ORDER BY, LIMIT,
FOR UPDATE, or WITH to VALUES, and hence to INSERT ... VALUES. But the
special-case code for VALUES in transformInsertStmt() wasn't expecting any
of those, and just ignored them, leading to unexpected results. Rather
than complicate the special-case path, just ensure that the presence of any
of those clauses makes us treat the query as if it had a general SELECT.
Per report from Hitoshi Harada.
Marc G. Fournier [Fri, 1 Oct 2010 13:36:12 +0000 (10:36 -0300)]
Tag 8.3.12
Tom Lane [Thu, 30 Sep 2010 21:21:04 +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
Peter Eisentraut [Thu, 30 Sep 2010 19:21:39 +0000 (22:21 +0300)]
Translation updates for 8.3.12
Tom Lane [Thu, 30 Sep 2010 18:27:41 +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.
Magnus Hagander [Thu, 16 Sep 2010 20:37:18 +0000 (20:37 +0000)]
Treat exit code 128 (ERROR_WAIT_NO_CHILDREN) as non-fatal on Win32,
since it can happen when a process fails to start when the system
is under high load.
Per several bug reports and many peoples investigation.
Back-patch to 8.2, since testing shows no issues even though the
"deadman-switch" does not exist in this version.
Tom Lane [Tue, 28 Sep 2010 20:13:09 +0000 (16:13 -0400)]
Fix incorrect usage of non-strict OR joinclauses in appendrel indexscans.
By chance I happened to notice that bug #5076 was still broken in the
8.3 branch, though it worked everywhere else. The reason is that 8.3's
version of adjust_appendrel_attrs_mutator neglected to adjust
RestrictInfo.nullable_relids. This was an oversight in my patch of
2009-04-16, which I apparently corrected in the later branches on
2009-08-13 without realizing that it affected the 8.3 branch as well.
By the time the bug report was filed, it was not reproducible in 8.4.
I don't recall if I wrote it off as already fixed, or it just fell through
the cracks; but anyway it's been a live bug in 8.3 for a year.
Tom Lane [Tue, 28 Sep 2010 18:47:25 +0000 (14:47 -0400)]
Fix another small oversight in command_no_begin patch.
Need a "return false" to prevent tests from continuing after we've moved
the "query" pointer. As it stood, it'd accept "DROP DISCARD ALL" as a
match.
Itagaki Takahiro [Tue, 28 Sep 2010 06:57:40 +0000 (15:57 +0900)]
Only DISCARD ALL should be in the command_no_begin list.
We allowes DISCARD PLANS and TEMP in a transaction.
Itagaki Takahiro [Tue, 28 Sep 2010 05:27:53 +0000 (14:27 +0900)]
Add DISCARD to the command_no_begin list for AUTOCOMMIT=off.
Backpatch to 8.3.
Reported by Sergey Burladyan.
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.
Tom Lane [Fri, 24 Sep 2010 17:48:30 +0000 (13:48 -0400)]
Still more .gitignore cleanup.
Fix overly-enthusiastic ignores, as identified by
git ls-files -i --exclude-standard
Robert Haas [Fri, 24 Sep 2010 02:00:26 +0000 (22:00 -0400)]
Add contrib/xml2/pgxml.sql to .gitignore
Kevin Grittner
Tom Lane [Thu, 23 Sep 2010 20:53:33 +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.
Tom Lane [Thu, 23 Sep 2010 23:34:56 +0000 (19:34 -0400)]
Avoid sharing subpath list structure when flattening nested AppendRels.
In some situations the original coding led to corrupting the child AppendRel's
subpaths list, effectively adding other members of the parent's list to it.
This was usually masked because we never made any further use of the child's
list, but given the right combination of circumstances, we could do so. The
visible symptom would be a relation getting scanned twice, as in bug #5673
from David Schmitt.
Backpatch to 8.2, which is as far back as the risky coding appears. The
example submitted by David only fails in 8.4 and later, but I'm not convinced
that there aren't any even-more-obscure cases where 8.2 and 8.3 would fail.
Tom Lane [Thu, 23 Sep 2010 02:32:38 +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.
Tom Lane [Thu, 23 Sep 2010 00:22:47 +0000 (20:22 -0400)]
Do some copy-editing on the Git usage docs.
Tom Lane [Wed, 22 Sep 2010 22:26:21 +0000 (18:26 -0400)]
Fix documentation gitignore for pre-9.0 doc build methods.
Tom Lane [Wed, 22 Sep 2010 21:22:10 +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.
Magnus Hagander [Wed, 22 Sep 2010 19:49:13 +0000 (21:49 +0200)]
Add gitignore files for ecpg regression tests.
Backpatch to 8.2 as that's how far the structure looks the same.
Magnus Hagander [Wed, 22 Sep 2010 18:10:36 +0000 (20:10 +0200)]
Remove anonymous cvs instructions, and replace them with instructions
for git. Change other references from cvs to git as well.
Magnus Hagander [Wed, 22 Sep 2010 10:57:12 +0000 (12:57 +0200)]
Convert cvsignore to gitignore, and add .gitignore for build targets.
Tom Lane [Tue, 21 Sep 2010 18:43:11 +0000 (14:43 -0400)]
Back-patch replacement of README.CVS with README.git.
In older branches, also git-ify the "make distdir" rule.
Tom Lane [Thu, 2 Sep 2010 03:17:06 +0000 (03:17 +0000)]
Fix up flushing of composite-type typcache entries to be driven directly by
SI invalidation events, rather than indirectly through the relcache.
In the previous coding, we had to flush a composite-type typcache entry
whenever we discarded the corresponding relcache entry. This caused problems
at least when testing with RELCACHE_FORCE_RELEASE, as shown in recent report
from Jeff Davis, and might result in real-world problems given the kind of
unexpected relcache flush that that test mechanism is intended to model.
The new coding decouples relcache and typcache management, which is a good
thing anyway from a structural perspective. The cost is that we have to
search the typcache linearly to find entries that need to be flushed. There
are a couple of ways we could avoid that, but at the moment it's not clear
it's worth any extra trouble, because the typcache contains very few entries
in typical operation.
Back-patch to 8.2, the same as some other recent fixes in this general area.
The patch could be carried back to 8.0 with some additional work, but given
that it's only hypothetical whether we're fixing any problem observable in
the field, it doesn't seem worth the work now.
Tom Lane [Sun, 29 Aug 2010 19:33:36 +0000 (19:33 +0000)]
Reduce PANIC to ERROR in some occasionally-reported btree failure cases.
This patch changes _bt_split() and _bt_pagedel() to throw a plain ERROR,
rather than PANIC, for several cases that are reported from the field
from time to time:
* right sibling's left-link doesn't match;
* PageAddItem failure during _bt_split();
* parent page's next child isn't right sibling during _bt_pagedel().
In addition the error messages for these cases have been made a bit
more verbose, with additional values included.
The original motivation for PANIC here was to capture core dumps for
subsequent analysis. But with so many users whose platforms don't capture
core dumps by default, or who are unprepared to analyze them anyway, it's hard
to justify a forced database restart when we can fairly easily detect the
problems before we've reached the critical sections where PANIC would be
necessary. It is not currently known whether the reports of these messages
indicate well-hidden bugs in Postgres, or are a result of storage-level
malfeasance; the latter possibility suggests that we ought to try to be more
robust even if there is a bug here that's ultimately found.
Backpatch to 8.2. The code before that is sufficiently different that
it doesn't seem worth the trouble to back-port further.
Tom Lane [Sun, 29 Aug 2010 15:19:26 +0000 (15:19 +0000)]
Remove obsolete remark that PQprepare() is more flexible than PREPARE.
Spotted by Dmitriy Igrishin. Back-patch to 8.2, which is when the PREPARE
statement was improved to allow parameter types to be omitted.
Tom Lane [Thu, 26 Aug 2010 19:59:08 +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.
Tom Lane [Thu, 26 Aug 2010 18:54:59 +0000 (18:54 +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.
Peter Eisentraut [Wed, 25 Aug 2010 19:37:43 +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
Tom Lane [Thu, 19 Aug 2010 18:11:07 +0000 (18:11 +0000)]
Keep exec_simple_check_plan() from thinking "SELECT foo INTO bar" is simple.
It's not clear if this situation can occur in plpgsql other than via the
EXECUTE USING case Heikki illustrated, which I will shortly close off.
However, ignoring the intoClause if it's there is surely wrong, so let's
patch it for safety.
Backpatch to 8.3, which is as far back as this code has a PlannedStmt
to deal with. There might be another way to make an equivalent test
before that, but since this is just preventing hypothetical bugs,
I'm not going to obsess about it.
Tom Lane [Wed, 18 Aug 2010 15:22:15 +0000 (15:22 +0000)]
Add missing handling of PlannedStmt.transientPlan in copyfuncs/outfuncs.
_outPlannedStmt is only debug support, so the omission there was not very
serious, but the omission in _copyPlannedStmt is a real bug. The consequence
would be that a copied plan tree would never be marked as a transient plan,
so that we would forget we ought to replan it after some not-yet-ready index
becomes ready for use. This might explain some past complaints about indexes
created with CREATE INDEX CONCURRENTLY not being used right away. Problem
spotted by Yeb Havinga.
Back-patch to 8.3, where the field was added.
Peter Eisentraut [Tue, 17 Aug 2010 04:49:32 +0000 (04:49 +0000)]
Backpatch some blatant spelling mistakes
Tom Lane [Mon, 16 Aug 2010 17:33:07 +0000 (17:33 +0000)]
Arrange to fsync the contents of lockfiles (both postpid 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.
Tom Lane [Mon, 16 Aug 2010 00:06:37 +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.
Tom Lane [Fri, 13 Aug 2010 16:27:35 +0000 (16:27 +0000)]
Fix Assert failure in PushOverrideSearchPath when trying to restore a search
path that specifies useTemp, but there is no active temp schema in the
current session. (This can happen if the path was saved during a transaction
that created a temp schema and was later rolled back.) For existing callers
it's sufficient to ignore the useTemp flag in this case, though we might
later want to offer an option to create a fresh temp schema. So far as I can
tell this is just an Assert failure: in a non-assert build, the code would
push a zero onto the new search path, which is useless but not very harmful.
Per bug report from Heikki.
Back-patch to 8.3; prior versions don't have this code.
Robert Haas [Wed, 11 Aug 2010 19:03:46 +0000 (19:03 +0000)]
Fix one more incorrect errno definition in the ECPG manual.
Again, back-patch all the way to 7.4.
Robert Haas [Wed, 11 Aug 2010 18:52:33 +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
Tom Lane [Mon, 9 Aug 2010 18:50:37 +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
Peter Eisentraut [Fri, 6 Aug 2010 20:08:59 +0000 (20:08 +0000)]
Fix indexterm spelling
Tom Lane [Tue, 3 Aug 2010 00:10:58 +0000 (00:10 +0000)]
Fix core dump in QTNodeCompare when tsquery_cmp() is applied to two empty
tsqueries. CompareTSQ has to have a guard for the case rather than blindly
applying QTNodeCompare to random data past the end of the datums. Also,
change QTNodeCompare to be a little less trusting: use an actual test rather
than just Assert'ing that the input is sane. Problem encountered while
investigating another issue (I saw a core dump in autoanalyze on a table
containing multiple empty tsquery values).
Back-patch to all branches with tsquery support.
In HEAD, also fix some bizarre (though not outright wrong) coding in
tsq_mcontains().
Tom Lane [Fri, 30 Jul 2010 17:57:07 +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.
Tom Lane [Thu, 29 Jul 2010 19:23:44 +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.
Robert Haas [Thu, 29 Jul 2010 16:15:05 +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.
Tom Lane [Wed, 28 Jul 2010 04:51:14 +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.
Peter Eisentraut [Tue, 27 Jul 2010 18:55:44 +0000 (18:55 +0000)]
Spelling fix
Peter Eisentraut [Mon, 26 Jul 2010 20:29:35 +0000 (20:29 +0000)]
Fix grammar
backpatched to 8.1
Robert Haas [Fri, 23 Jul 2010 00:43:26 +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.
Heikki Linnakangas [Tue, 13 Jul 2010 09:02:46 +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.
Tom Lane [Fri, 9 Jul 2010 22:58:01 +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.
Tom Lane [Thu, 8 Jul 2010 00:14:16 +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.
Heikki Linnakangas [Mon, 5 Jul 2010 09:27:31 +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.
Robert Haas [Sat, 3 Jul 2010 13:53:38 +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.
Tom Lane [Sat, 3 Jul 2010 04:03:21 +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.
Robert Haas [Thu, 1 Jul 2010 14:11:42 +0000 (14:11 +0000)]
Allow ALTER TABLE .. SET TABLESPACE to be interrupted.
Backpatch to 8.0, where tablespaces were introduced.
Guillaume Lelarge
Heikki Linnakangas [Wed, 30 Jun 2010 18:10:51 +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.
Robert Haas [Tue, 22 Jun 2010 11:36:36 +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.
Tom Lane [Tue, 15 Jun 2010 19:04:28 +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.
Tom Lane [Tue, 15 Jun 2010 16:22:33 +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.
Tom Lane [Mon, 14 Jun 2010 20:49:46 +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.
Magnus Hagander [Wed, 9 Jun 2010 10:54:50 +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.
Itagaki Takahiro [Wed, 9 Jun 2010 00:59:35 +0000 (00:59 +0000)]
Fix connection leak in dblink when dblink_connect() or dblink_connect_u()
end with "duplicate connection name" errors.
Backported to release 7.4.
Teodor Sigaev [Mon, 7 Jun 2010 15:15:03 +0000 (15:15 +0000)]
Add missed function dblink_connect_u(text[,text]) to uninstall script
Michael Meskes [Fri, 4 Jun 2010 10:48:34 +0000 (10:48 +0000)]
Data returned by RETURNING clause wasn't correctly processed by ecpg. Patch backported from HEAD.
Andrew Dunstan [Thu, 3 Jun 2010 11:04:12 +0000 (11:04 +0000)]
Fix regression test name for plperlu_plperl in msvc.
Itagaki Takahiro [Thu, 3 Jun 2010 09:41:26 +0000 (09:41 +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.
Andrew Dunstan [Wed, 2 Jun 2010 15:58:08 +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.
Tom Lane [Fri, 28 May 2010 17:35:36 +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.
Tom Lane [Fri, 28 May 2010 01:14:16 +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.
Tom Lane [Thu, 27 May 2010 19:19:50 +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.
Magnus Hagander [Thu, 20 May 2010 14:13:20 +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
Andrew Dunstan [Mon, 17 May 2010 20:46:40 +0000 (20:46 +0000)]
> Follow up a visit from the style police.
Robert Haas [Sun, 16 May 2010 03:56:19 +0000 (03:56 +0000)]
Fix longstanding typo in V1 calling conventions documentation.
Erik Rijkers
Tom Lane [Sat, 15 May 2010 18:11:19 +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.
Heikki Linnakangas [Sat, 15 May 2010 09:32:09 +0000 (09:32 +0000)]
Fix typos in comments, spotted by Josh Kupershmidt.
Marc G. Fournier [Fri, 14 May 2010 03:27:08 +0000 (03:27 +0000)]
tag 8.3.11
Andrew Dunstan [Thu, 13 May 2010 21:34:30 +0000 (21:34 +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
Tom Lane [Thu, 13 May 2010 21:27:15 +0000 (21:27 +0000)]
Update release notes with security issues.
Security: CVE-2010-1169, CVE-2010-1170
Tom Lane [Thu, 13 May 2010 19:16:27 +0000 (19:16 +0000)]
Use an entity instead of non-ASCII letter. Thom Brown
Tom Lane [Thu, 13 May 2010 18:29:25 +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
Andrew Dunstan [Thu, 13 May 2010 16:42:51 +0000 (16:42 +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
Magnus Hagander [Thu, 13 May 2010 14:16:51 +0000 (14:16 +0000)]
Fix some spelling errors.
Thom Brown
Peter Eisentraut [Thu, 13 May 2010 07:37:42 +0000 (07:37 +0000)]
Translation update
Tom Lane [Wed, 12 May 2010 23:27:36 +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.
Tom Lane [Tue, 11 May 2010 23:01:41 +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.
Tom Lane [Tue, 11 May 2010 22:37:05 +0000 (22:37 +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.
Tom Lane [Tue, 11 May 2010 16:42:40 +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.
Itagaki Takahiro [Tue, 11 May 2010 04:57:51 +0000 (04:57 +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.
Tom Lane [Sat, 8 May 2010 16:40:14 +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".
Tom Lane [Wed, 5 May 2010 22:19:11 +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.
Heikki Linnakangas [Wed, 5 May 2010 15:14:24 +0000 (15:14 +0000)]
Fix incorrect parameter tag in docs, spotted by KOIZUMI Satoru.
Tom Lane [Sat, 1 May 2010 22:46:42 +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.
Tom Lane [Fri, 30 Apr 2010 19:15:58 +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.
Robert Haas [Mon, 19 Apr 2010 00:00:22 +0000 (00:00 +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".
Heikki Linnakangas [Fri, 16 Apr 2010 09:52:01 +0000 (09:52 +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.
Tom Lane [Thu, 15 Apr 2010 21:05:17 +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).
Peter Eisentraut [Thu, 15 Apr 2010 20:47:06 +0000 (20:47 +0000)]
IP port -> TCP port
backpatched to 8.1, where this first appeared
Tom Lane [Wed, 14 Apr 2010 21:31:27 +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.