]> granicus.if.org Git - postgresql/log
postgresql
10 years agoEnsure _dosmaperr() actually sets errno correctly.
Tom Lane [Sat, 23 Nov 2013 23:24:26 +0000 (18:24 -0500)]
Ensure _dosmaperr() actually sets errno correctly.

If logging is enabled, either ereport() or fprintf() might stomp on errno
internally, causing this function to return the wrong result.  That might
only end in a misleading error report, but in any code that's examining
errno to decide what to do next, the consequences could be far graver.

This has been broken since the very first version of this file in 2006
... it's a bit astonishing that we didn't identify this long ago.

Reported by Amit Kapila, though this isn't his proposed fix.

10 years agoAvoid potential buffer overflow crash
Peter Eisentraut [Sat, 23 Nov 2013 12:25:37 +0000 (07:25 -0500)]
Avoid potential buffer overflow crash

A pointer to a C string was treated as a pointer to a "name" datum and
passed to SPI_execute_plan().  This pointer would then end up being
passed through datumCopy(), which would try to copy the entire 64 bytes
of name data, thus running past the end of the C string.  Fix by
converting the string to a proper name structure.

Found by LLVM AddressSanitizer.

10 years agoFlatten join alias Vars before pulling up targetlist items from a subquery.
Tom Lane [Fri, 22 Nov 2013 19:37:25 +0000 (14:37 -0500)]
Flatten join alias Vars before pulling up targetlist items from a subquery.

pullup_replace_vars()'s decisions about whether a pulled-up replacement
expression needs to be wrapped in a PlaceHolderVar depend on the assumption
that what looks like a Var behaves like a Var.  However, if the Var is a
join alias reference, later flattening of join aliases might replace the
Var with something that's not a Var at all, and should have been wrapped.

To fix, do a forcible pass of flatten_join_alias_vars() on the subquery
targetlist before we start to copy items out of it.  We'll re-run that
processing on the pulled-up expressions later, but that's harmless.

Per report from Ken Tanzer; the added regression test case is based on his
example.  This bug has been there since the PlaceHolderVar mechanism was
invented, but has escaped detection because the circumstances that trigger
it are fairly narrow.  You need a flattenable query underneath an outer
join, which contains another flattenable query inside a join of its own,
with a dangerous expression (a constant or something else non-strict)
in that one's targetlist.

Having seen this, I'm wondering if it wouldn't be prudent to do all
alias-variable flattening earlier, perhaps even in the rewriter.
But that would probably not be a back-patchable change.

10 years agoFix quoting in help messages in uuid-ossp extension scripts.
Tom Lane [Fri, 22 Nov 2013 17:07:53 +0000 (12:07 -0500)]
Fix quoting in help messages in uuid-ossp extension scripts.

The command we're telling people to type needs to include double-quoting
around the unfortunately-chosen extension name.  Twiddle the textual
quoting so that it looks somewhat sane.  Per gripe from roadrunner6.

10 years agoFix Hot-Standby initialization of clog and subtrans.
Heikki Linnakangas [Fri, 22 Nov 2013 12:38:59 +0000 (14:38 +0200)]
Fix Hot-Standby initialization of clog and subtrans.

These bugs can cause data loss on standbys started with hot_standby=on at
the moment they start to accept read only queries, by marking committed
transactions as uncommited. The likelihood of such corruptions is small
unless the primary has a high transaction rate.

5a031a5556ff83b8a9646892715d7fef415b83c3 fixed bugs in HS's startup logic
by maintaining less state until at least STANDBY_SNAPSHOT_PENDING state
was reached, missing the fact that both clog and subtrans are written to
before that. This only failed to fail in common cases because the usage
of ExtendCLOG in procarray.c was superflous since clog extensions are
actually WAL logged.

f44eedc3f0f347a856eea8590730769125964597/I then tried to fix the missing
extensions of pg_subtrans due to the former commit's changes - which are
not WAL logged - by performing the extensions when switching to a state
> STANDBY_INITIALIZED and not performing xid assignments before that -
again missing the fact that ExtendCLOG is unneccessary - but screwed up
twice: Once because latestObservedXid wasn't updated anymore in that
state due to the earlier commit and once by having an off-by-one error in
the loop performing extensions. This means that whenever a
CLOG_XACTS_PER_PAGE (32768 with default settings) boundary was crossed
between the start of the checkpoint recovery started from and the first
xl_running_xact record old transactions commit bits in pg_clog could be
overwritten if they started and committed in that window.

Fix this mess by not performing ExtendCLOG() in HS at all anymore since
it's unneeded and evidently dangerous and by performing subtrans
extensions even before reaching STANDBY_SNAPSHOT_PENDING.

Analysis and patch by Andres Freund. Reported by Christophe Pettus.
Backpatch down to 9.0, like the previous commit that caused this.

10 years agoFix pg_isready to handle -d option properly.
Fujii Masao [Thu, 21 Nov 2013 12:52:03 +0000 (21:52 +0900)]
Fix pg_isready to handle -d option properly.

Previously, -d option for pg_isready was broken. When the name of the
database was specified by -d option, pg_isready failed with an error.
When the conninfo specified by -d option contained the setting of the
host name but not Numeric IP address (i.e., hostaddr), pg_isready
displayed wrong connection message. -d option could not handle a valid
URI prefix at all. This commit fixes these bugs of pg_isready.

Backpatch to 9.3, where pg_isready was introduced.

Per report from Josh Berkus and Robert Haas.
Original patch by Fabrízio de Royes Mello, heavily modified by me.

10 years agodocs: update page format to specify page checksum field
Bruce Momjian [Tue, 19 Nov 2013 21:54:42 +0000 (16:54 -0500)]
docs:  update page format to specify page checksum field

Backpatch to 9.3

Per report from Steffen Hildebrandt

10 years agopg_upgrade: Report full disk better
Peter Eisentraut [Tue, 19 Nov 2013 02:49:40 +0000 (21:49 -0500)]
pg_upgrade: Report full disk better

Previously, pg_upgrade would abort copy_file() on a short write without
setting errno, which the caller would report as an error with the
message "Success".  We assume ENOSPC in that case, as we do elsewhere in
the code.  Also set errno in some other error cases in copy_file() to
avoid bogus "Success" error messages.

This was broken in 6b711cf37c228749b6a8cef50e16e3c587d18dd4, so 9.2 and
before are OK.

10 years agoCount locked pages that don't need vacuuming as scanned.
Heikki Linnakangas [Mon, 18 Nov 2013 07:51:09 +0000 (09:51 +0200)]
Count locked pages that don't need vacuuming as scanned.

Previously, if VACUUM skipped vacuuming a page because it's pinned, it
didn't count that page as scanned. However, that meant that relfrozenxid
was not bumped up either, which prevented anti-wraparound vacuum from
doing its job.

Report by Миша Тюрин, analysis and patch by Sergey Burladyn and Jeff Janes.
Backpatch to 9.2, where the skip-locked-pages behavior was introduced.

10 years agoFix incorrect loop counts in tidbitmap.c.
Tom Lane [Fri, 15 Nov 2013 23:34:14 +0000 (18:34 -0500)]
Fix incorrect loop counts in tidbitmap.c.

A couple of places that should have been iterating over WORDS_PER_CHUNK
words were iterating over WORDS_PER_PAGE words instead.  This thinko
accidentally failed to fail, because (at least on common architectures
with default BLCKSZ) WORDS_PER_CHUNK is a bit less than WORDS_PER_PAGE,
and the extra words being looked at were always zero so nothing happened.
Still, it's a bug waiting to happen if anybody ever fools with the
parameters affecting TIDBitmap sizes, and it's a small waste of cycles
too.  So back-patch to all active branches.

Etsuro Fujita

10 years agoCompute correct em_nullable_relids in get_eclass_for_sort_expr().
Tom Lane [Fri, 15 Nov 2013 21:46:21 +0000 (16:46 -0500)]
Compute correct em_nullable_relids in get_eclass_for_sort_expr().

Bug #8591 from Claudio Freire demonstrates that get_eclass_for_sort_expr
must be able to compute valid em_nullable_relids for any new equivalence
class members it creates.  I'd worried about this in the commit message
for db9f0e1d9a4a0842c814a464cdc9758c3f20b96c, but claimed that it wasn't a
problem because multi-member ECs should already exist when it runs.  That
is transparently wrong, though, because this function is also called by
initialize_mergeclause_eclasses, which runs during deconstruct_jointree.
The example given in the bug report (which the new regression test item
is based upon) fails because the COALESCE() expression is first seen by
initialize_mergeclause_eclasses rather than process_equivalence.

Fixing this requires passing the appropriate nullable_relids set to
get_eclass_for_sort_expr, and it requires new code to compute that set
for top-level expressions such as ORDER BY, GROUP BY, etc.  We store
the top-level nullable_relids in a new field in PlannerInfo to avoid
computing it many times.  In the back branches, I've added the new
field at the end of the struct to minimize ABI breakage for planner
plugins.  There doesn't seem to be a good alternative to changing
get_eclass_for_sort_expr's API signature, though.  There probably aren't
any third-party extensions calling that function directly; moreover,
if there are, they probably need to think about what to pass for
nullable_relids anyway.

Back-patch to 9.2, like the previous patch in this area.

10 years agodoc: Restore proper alphabetical order.
Robert Haas [Fri, 15 Nov 2013 13:44:18 +0000 (08:44 -0500)]
doc: Restore proper alphabetical order.

Colin 't Hart

10 years agoClarify CREATE FUNCTION documentation about handling of typmods.
Tom Lane [Wed, 13 Nov 2013 18:26:33 +0000 (13:26 -0500)]
Clarify CREATE FUNCTION documentation about handling of typmods.

The previous text was a bit misleading, as well as unnecessarily vague
about what information would be discarded.  Per gripe from Craig Skinner.

10 years agoFix doc links in README file to work with new website layout
Magnus Hagander [Tue, 12 Nov 2013 11:53:32 +0000 (12:53 +0100)]
Fix doc links in README file to work with new website layout

Per report from Colin 't Hart

10 years agoFix failure with whole-row reference to a subquery.
Tom Lane [Mon, 11 Nov 2013 21:36:27 +0000 (16:36 -0500)]
Fix failure with whole-row reference to a subquery.

Simple oversight in commit 1cb108efb0e60d87e4adec38e7636b6e8efbeb57 ---
recursively examining a subquery output column is only sane if the
original Var refers to a single output column.  Found by Kevin Grittner.

10 years agoFix ruleutils pretty-printing to not generate trailing whitespace.
Tom Lane [Mon, 11 Nov 2013 18:36:42 +0000 (13:36 -0500)]
Fix ruleutils pretty-printing to not generate trailing whitespace.

The pretty-printing logic in ruleutils.c operates by inserting a newline
and some indentation whitespace into strings that are already valid SQL.
This naturally results in leaving some trailing whitespace before the
newline in many cases; which can be annoying when processing the output
with other tools, as complained of by Joe Abbate.  We can fix that in
a pretty localized fashion by deleting any trailing whitespace before
we append a pretty-printing newline.  In addition, we have to modify the
code inserted by commit 2f582f76b1945929ff07116cd4639747ce9bb8a1 so that
we also delete trailing whitespace when transposing items from temporary
buffers into the main result string, when a temporary item starts with a
newline.

This results in rather voluminous changes to the regression test results,
but it's easily verified that they are only removal of trailing whitespace.

Back-patch to 9.3, because the aforementioned commit resulted in many
more cases of trailing whitespace than had occurred in earlier branches.

10 years agoRe-allow duplicate aliases within aliased JOINs.
Tom Lane [Mon, 11 Nov 2013 15:43:00 +0000 (10:43 -0500)]
Re-allow duplicate aliases within aliased JOINs.

Although the SQL spec forbids duplicate table aliases, historically
we've allowed queries like
    SELECT ... FROM tab1 x CROSS JOIN (tab2 x CROSS JOIN tab3 y) z
on the grounds that the aliased join (z) hides the aliases within it,
therefore there is no conflict between the two RTEs named "x".  The
LATERAL patch broke this, on the misguided basis that "x" could be
ambiguous if tab3 were a LATERAL subquery.  To avoid breaking existing
queries, it's better to allow this situation and complain only if
tab3 actually does contain an ambiguous reference.  We need only remove
the check that was throwing an error, because the column lookup code
is already prepared to handle ambiguous references.  Per bug #8444.

10 years agoDon't abort pg_basebackup when receiving empty WAL block
Magnus Hagander [Mon, 11 Nov 2013 13:59:55 +0000 (14:59 +0100)]
Don't abort pg_basebackup when receiving empty WAL block

This is a similar fix as c6ec8793aa59d1842082e14b4b4aae7d4bd883fd
9.2. This should never happen in 9.3 and newer since the special case
cannot happen there, but this patch synchronizes up the code so there
is no confusion on why they're different. An empty block is as harmless
in 9.3 as it was in 9.2, and can safely be ignored.

10 years agoFix race condition in GIN posting tree page deletion.
Heikki Linnakangas [Fri, 8 Nov 2013 20:21:42 +0000 (22:21 +0200)]
Fix race condition in GIN posting tree page deletion.

If a page is deleted, and reused for something else, just as a search is
following a rightlink to it from its left sibling, the search would continue
scanning whatever the new contents of the page are. That could lead to
incorrect query results, or even something more curious if the page is
reused for a different kind of a page.

To fix, modify the search algorithm to lock the next page before releasing
the previous one, and refrain from deleting pages from the leftmost branch
of the tree.

Add a new Concurrency section to the README, explaining why this works.
There is a lot more one could say about concurrency in GIN, but that's for
another patch.

Backpatch to all supported versions.

10 years agoMake contain_volatile_functions/contain_mutable_functions look into SubLinks.
Tom Lane [Fri, 8 Nov 2013 16:37:00 +0000 (11:37 -0500)]
Make contain_volatile_functions/contain_mutable_functions look into SubLinks.

This change prevents us from doing inappropriate subquery flattening in
cases such as dangerous functions hidden inside a sub-SELECT in the
targetlist of another sub-SELECT.  That could result in unexpected behavior
due to multiple evaluations of a volatile function, as in a recent
complaint from Etienne Dube.  It's been questionable from the very
beginning whether these functions should look into subqueries (as noted in
their comments), and this case seems to provide proof that they should.

Because the new code only descends into SubLinks, not SubPlans or
InitPlans, the change only affects the planner's behavior during
prepjointree processing and not later on --- for example, you can still get
it to use a volatile function in an indexqual if you wrap the function in
(SELECT ...).  That's a historical behavior, for sure, but it's reasonable
given that the executor's evaluation rules for subplans don't depend on
whether there are volatile functions inside them.  In any case, we need to
constrain the behavioral change as narrowly as we can to make this
reasonable to back-patch.

10 years agoFix subtly-wrong volatility checking in BeginCopyFrom().
Tom Lane [Fri, 8 Nov 2013 13:59:43 +0000 (08:59 -0500)]
Fix subtly-wrong volatility checking in BeginCopyFrom().

contain_volatile_functions() is best applied to the output of
expression_planner(), not its input, so that insertion of function
default arguments and constant-folding have been done.  (See comments
at CheckMutability, for instance.)  It's perhaps unlikely that anyone
will notice a difference in practice, but still we should do it properly.

In passing, change variable type from Node* to Expr* to reduce the net
number of casts needed.

Noted while perusing uses of contain_volatile_functions().

10 years agoBe more robust when strerror() doesn't give a useful result.
Tom Lane [Thu, 7 Nov 2013 21:33:18 +0000 (16:33 -0500)]
Be more robust when strerror() doesn't give a useful result.

Back-patch commits 8e68816cc2567642c6fcca4eaac66c25e0ae5ced and
8dace66e0735ca39b779922d02c24ea2686e6521 into the stable branches.
Buildfarm testing revealed no great portability surprises, and it
seems useful to have this robustness improvement in all branches.

10 years agoPrevent display of dropped columns in row constraint violation messages.
Tom Lane [Thu, 7 Nov 2013 19:41:39 +0000 (14:41 -0500)]
Prevent display of dropped columns in row constraint violation messages.

ExecBuildSlotValueDescription() printed "null" for each dropped column in
a row being complained of by ExecConstraints().  This has some sanity in
terms of the underlying implementation, but is of course pretty surprising
to users.  To fix, we must pass the target relation's descriptor to
ExecBuildSlotValueDescription(), because the slot descriptor it had been
using doesn't get labeled with attisdropped markers.

Per bug #8408 from Maxim Boguk.  Back-patch to 9.2 where the feature of
printing row values in NOT NULL and CHECK constraint violation messages
was introduced.

Michael Paquier and Tom Lane

10 years agoFix generation of MergeAppend plans for optimized min/max on expressions.
Tom Lane [Thu, 7 Nov 2013 18:13:15 +0000 (13:13 -0500)]
Fix generation of MergeAppend plans for optimized min/max on expressions.

Before jamming a desired targetlist into a plan node, one really ought to
make sure the plan node can handle projections, and insert a buffering
Result plan node if not.  planagg.c forgot to do this, which is a hangover
from the days when it only dealt with IndexScan plan types.  MergeAppend
doesn't project though, not to mention that it gets unhappy if you remove
its possibly-resjunk sort columns.  The code accidentally failed to fail
for cases in which the min/max argument was a simple Var, because the new
targetlist would be equivalent to the original "flat" tlist anyway.
For any more complex case, it's been broken since 9.1 where we introduced
the ability to optimize min/max using MergeAppend, as reported by Raphael
Bauduin.  Fix by duplicating the logic from grouping_planner that decides
whether we need a Result node.

In 9.2 and 9.1, this requires back-porting the tlist_same_exprs() function
introduced in commit 4387cf956b9eb13aad569634e0c4df081d76e2e3, else we'd
uselessly add a Result node in cases that worked before.  It's rather
tempting to back-patch that whole commit so that we can avoid extra Result
nodes in mainline cases too; but I'll refrain, since that code hasn't
really seen all that much field testing yet.

10 years agoSupport default arguments and named-argument notation for window functions.
Tom Lane [Wed, 6 Nov 2013 18:26:34 +0000 (13:26 -0500)]
Support default arguments and named-argument notation for window functions.

These things didn't work because the planner omitted to do the necessary
preprocessing of a WindowFunc's argument list.  Add the few dozen lines
of code needed to handle that.

Although this sounds like a feature addition, it's really a bug fix because
the default-argument case was likely to crash previously, due to lack of
checking of the number of supplied arguments in the built-in window
functions.  It's not a security issue because there's no way for a
non-superuser to create a window function definition with defaults that
refers to a built-in C function, but nonetheless people might be annoyed
that it crashes rather than producing a useful error message.  So
back-patch as far as the patch applies easily, which turns out to be 9.2.
I'll put a band-aid in earlier versions as a separate patch.

(Note that these features still don't work for aggregates, and fixing that
case will be harder since we represent aggregate arg lists as target lists
not bare expression lists.  There's no crash risk though because CREATE
AGGREGATE doesn't accept defaults, and we reject named-argument notation
when parsing an aggregate call.)

10 years agoKeep heap open until new heap generated in RMV.
Kevin Grittner [Wed, 6 Nov 2013 18:26:36 +0000 (12:26 -0600)]
Keep heap open until new heap generated in RMV.

Early close became apparent when invalidation messages were
processed in a new location under CLOBBER_CACHE_ALWAYS builds, due
to additional locking.

Back-patch to 9.3

10 years agoImprove the error message given for modifying a window with frame clause.
Tom Lane [Wed, 6 Nov 2013 02:58:12 +0000 (21:58 -0500)]
Improve the error message given for modifying a window with frame clause.

For rather inscrutable reasons, SQL:2008 disallows copying-and-modifying a
window definition that has any explicit framing clause.  The error message
we gave for this only made sense if the referencing window definition
itself contains an explicit framing clause, which it might well not.
Moreover, in the context of an OVER clause it's not exactly obvious that
"OVER (windowname)" implies copy-and-modify while "OVER windowname" does
not.  This has led to multiple complaints, eg bug #5199 from Iliya
Krapchatov.  Change to a hopefully more intelligible error message, and
in the case where we have just "OVER (windowname)", add a HINT suggesting
that omitting the parentheses will fix it.  Also improve the related
documentation.  Back-patch to all supported branches.

10 years agoFix breakage of MV column name list usage.
Kevin Grittner [Mon, 4 Nov 2013 20:45:18 +0000 (14:45 -0600)]
Fix breakage of MV column name list usage.

Per bug report from Tomonari Katsumata.

Back-patch to 9.3.

10 years agoFix parsing of xlog file name in pg_receivexlog.
Heikki Linnakangas [Mon, 4 Nov 2013 08:51:37 +0000 (10:51 +0200)]
Fix parsing of xlog file name in pg_receivexlog.

The parsing of WAL filenames of segments larger than > 255 was broken,
making pg_receivexlog unable to restart streaming after stopping it.

The bug was introduced by the changes in 9.3 to represent WAL segment number
as a 64-bit integer instead of two ints, log and seg. To fix, replace the
plain sscanf call with XLogFromFileName macro, which does the conversion
from log+seg to a 64-bit integer correcly.

Reported by Mika Eloranta.

10 years agoPrevent memory leaks from accumulating across printtup() calls.
Tom Lane [Sun, 3 Nov 2013 16:33:09 +0000 (11:33 -0500)]
Prevent memory leaks from accumulating across printtup() calls.

Historically, printtup() has assumed that it could prevent memory leakage
by pfree'ing the string result of each output function and manually
managing detoasting of toasted values.  This amounts to assuming that
datatype output functions never leak any memory internally; an assumption
we've already decided to be bogus elsewhere, for example in COPY OUT.
range_out in particular is known to leak multiple kilobytes per call, as
noted in bug #8573 from Godfried Vanluffelen.  While we could go in and fix
that leak, it wouldn't be very notationally convenient, and in any case
there have been and undoubtedly will again be other leaks in other output
functions.  So what seems like the best solution is to run the output
functions in a temporary memory context that can be reset after each row,
as we're doing in COPY OUT.  Some quick experimentation suggests this is
actually a tad faster than the retail pfree's anyway.

This patch fixes all the variants of printtup, except for debugtup()
which is used in standalone mode.  It doesn't seem worth worrying
about query-lifespan leaks in standalone mode, and fixing that case
would be a bit tedious since debugtup() doesn't currently have any
startup or shutdown functions.

While at it, remove manual detoast management from several other
output-function call sites that had copied it from printtup().  This
doesn't make a lot of difference right now, but in view of recent
discussions about supporting "non-flattened" Datums, we're going to
want that code gone eventually anyway.

Back-patch to 9.2 where range_out was introduced.  We might eventually
decide to back-patch this further, but in the absence of known major
leaks in older output functions, I'll refrain for now.

10 years agoChanged test case slightly so it doesn't have an unused typedef.
Michael Meskes [Sun, 3 Nov 2013 14:37:34 +0000 (15:37 +0100)]
Changed test case slightly so it doesn't have an unused typedef.

10 years agoAcquire appropriate locks when rewriting during RMV.
Kevin Grittner [Sun, 3 Nov 2013 00:18:41 +0000 (19:18 -0500)]
Acquire appropriate locks when rewriting during RMV.

Since the query has not been freshly parsed when executing REFRESH
MATERIALIZED VIEW, locks must be explicitly taken before rewrite.

Backpatch to 9.3.

Andres Freund

10 years agoFix subquery reference to non-populated MV in CMV.
Kevin Grittner [Sat, 2 Nov 2013 23:31:41 +0000 (18:31 -0500)]
Fix subquery reference to non-populated MV in CMV.

A subquery reference to a matview should be allowed by CREATE
MATERIALIZED VIEW WITH NO DATA, just like a direct reference is.

Per bug report from Laurent Sartran.

Backpatch to 9.3.

10 years agoRetry after buffer locking failure during SPGiST index creation.
Tom Lane [Sat, 2 Nov 2013 20:45:42 +0000 (16:45 -0400)]
Retry after buffer locking failure during SPGiST index creation.

The original coding thought this case was impossible, but it can happen
if the bgwriter or checkpointer processes decide to write out an index
page while creation is still proceeding, leading to a bogus "unexpected
spgdoinsert() failure" error.  Problem reported by Jonathan S. Katz.

Teodor Sigaev

10 years agoEnsure all files created for a single BufFile have the same resource owner.
Tom Lane [Fri, 1 Nov 2013 20:09:52 +0000 (16:09 -0400)]
Ensure all files created for a single BufFile have the same resource owner.

Callers expect that they only have to set the right resource owner when
creating a BufFile, not during subsequent operations on it.  While we could
insist this be fixed at the caller level, it seems more sensible for the
BufFile to take care of it.  Without this, some temp files belonging to
a BufFile can go away too soon, eg at the end of a subtransaction,
leading to errors or crashes.

Reported and fixed by Andres Freund.  Back-patch to all active branches.

10 years agoFix some odd behaviors when using a SQL-style simple GMT offset timezone.
Tom Lane [Fri, 1 Nov 2013 16:13:23 +0000 (12:13 -0400)]
Fix some odd behaviors when using a SQL-style simple GMT offset timezone.

Formerly, when using a SQL-spec timezone setting with a fixed GMT offset
(called a "brute force" timezone in the code), the session_timezone
variable was not updated to match the nominal timezone; rather, all code
was expected to ignore session_timezone if HasCTZSet was true.  This is
of course obviously fragile, though a search of the code finds only
timeofday() failing to honor the rule.  A bigger problem was that
DetermineTimeZoneOffset() supposed that if its pg_tz parameter was
pointer-equal to session_timezone, then HasCTZSet should override the
parameter.  This would cause datetime input containing an explicit zone
name to be treated as referencing the brute-force zone instead, if the
zone name happened to match the session timezone that had prevailed
before installing the brute-force zone setting (as reported in bug #8572).
The same malady could affect AT TIME ZONE operators.

To fix, set up session_timezone so that it matches the brute-force zone
specification, which we can do using the POSIX timezone definition syntax
"<abbrev>offset", and get rid of the bogus lookaside check in
DetermineTimeZoneOffset().  Aside from fixing the erroneous behavior in
datetime parsing and AT TIME ZONE, this will cause the timeofday() function
to print its result in the user-requested time zone rather than some
previously-set zone.  It might also affect results in third-party
extensions, if there are any that make use of session_timezone without
considering HasCTZSet, but in all cases the new behavior should be saner
than before.

Back-patch to all supported branches.

10 years agoPrevent using strncpy with src == dest in TupleDescInitEntry.
Tom Lane [Tue, 29 Oct 2013 00:49:28 +0000 (20:49 -0400)]
Prevent using strncpy with src == dest in TupleDescInitEntry.

The C and POSIX standards state that strncpy's behavior is undefined when
source and destination areas overlap.  While it remains dubious whether any
implementations really misbehave when the pointers are exactly equal, some
platforms are now starting to force the issue by complaining when an
undefined call occurs.  (In particular OS X 10.9 has been seen to dump core
here, though the exact set of circumstances needed to trigger that remain
elusive.  Similar behavior can be expected to be optional on Linux and
other platforms in the near future.)  So tweak the code to explicitly do
nothing when nothing need be done.

Back-patch to all active branches.  In HEAD, this also lets us get rid of
an exception in valgrind.supp.

Per discussion of a report from Matthias Schmitt.

10 years agoWork around NetBSD shell issue in pg_upgrade test script.
Andrew Dunstan [Mon, 28 Oct 2013 15:45:50 +0000 (11:45 -0400)]
Work around NetBSD shell issue in pg_upgrade test script.

The NetBSD shell apparently returns non-zero from an unset command if
the variable is already unset. This matters when, as in pg_upgrade's
test.sh, we are working under 'set -e'. To protect against this, we
first set the PG variables to an empty string before unsetting them
completely.

Error found on buildfarm member coypu, solution from Rémi Zara.

10 years agoImprove documentation about usage of FDW validator functions.
Tom Lane [Mon, 28 Oct 2013 14:28:35 +0000 (10:28 -0400)]
Improve documentation about usage of FDW validator functions.

SGML documentation, as well as code comments, failed to note that an FDW's
validator will be applied to foreign-table options for foreign tables using
the FDW.

Etsuro Fujita

10 years agoPlug memory leak when reloading config file.
Heikki Linnakangas [Thu, 24 Oct 2013 12:21:50 +0000 (15:21 +0300)]
Plug memory leak when reloading config file.

The absolute path to config file was not pfreed. There are probably more
small leaks here and there in the config file reload code and assign hooks,
and in practice no-one reloads the config files frequently enough for it to
be a problem, but this one is trivial enough that might as well fix it.

Backpatch to 9.3 where the leak was introduced.

10 years agoFix memory leak when an empty ident file is reloaded.
Heikki Linnakangas [Thu, 24 Oct 2013 11:03:26 +0000 (14:03 +0300)]
Fix memory leak when an empty ident file is reloaded.

Hari Babu

10 years agoFix typos in comments.
Heikki Linnakangas [Thu, 24 Oct 2013 08:50:02 +0000 (11:50 +0300)]
Fix typos in comments.

10 years agoFix two bugs in setting the vm bit of empty pages.
Heikki Linnakangas [Wed, 23 Oct 2013 11:03:54 +0000 (14:03 +0300)]
Fix two bugs in setting the vm bit of empty pages.

Use a critical section when setting the all-visible flag on an empty page,
and WAL-logging it. log_newpage_buffer() contains an assertion that it
must be called inside a critical section, and it's the right thing to do
when modifying a buffer anyway.

Also, the page should be marked dirty before calling log_newpage_buffer(),
per the comment in log_newpage_buffer() and src/backend/access/transam/README.

Patch by Andres Freund, in response to my report. Backpatch to 9.2, like
the patch that introduced these bugs (a6370fd9).

10 years agoAdd libpgcommon to backend gettext source files
Peter Eisentraut [Sat, 19 Oct 2013 17:49:05 +0000 (13:49 -0400)]
Add libpgcommon to backend gettext source files

This ought to have been done when libpgcommon was split off from
libpgport.

10 years agoReturn valid json when converting an empty hstore.
Andrew Dunstan [Thu, 17 Oct 2013 15:09:55 +0000 (11:09 -0400)]
Return valid json when converting an empty hstore.

Oskari Saarenmaa.

10 years agodocs: correct 9.1 and 9.2 release note mention of timeline switch fix
Bruce Momjian [Tue, 15 Oct 2013 14:34:05 +0000 (10:34 -0400)]
docs: correct 9.1 and 9.2 release note mention of timeline switch fix

Backpatch through 9.1.

KONDO Mitsumasa

10 years agodoc: Fix table column number declaration
Peter Eisentraut [Fri, 11 Oct 2013 01:17:31 +0000 (21:17 -0400)]
doc: Fix table column number declaration

10 years agodoc: fix typo in release notes
Bruce Momjian [Wed, 9 Oct 2013 12:44:52 +0000 (08:44 -0400)]
doc:  fix typo in release notes

Backpatch through 8.4

Per suggestion by Amit Langote

10 years agodocs: clarify references to md5 hash and md5 crypt in pgcrypto docs
Bruce Momjian [Tue, 8 Oct 2013 16:25:18 +0000 (12:25 -0400)]
docs:  clarify references to md5 hash and md5 crypt in pgcrypto docs

Backpatch to 9.3.X.

Suggestion from Richard Neill

10 years agoStamp 9.3.1. REL9_3_1
Peter Eisentraut [Tue, 8 Oct 2013 03:17:38 +0000 (23:17 -0400)]
Stamp 9.3.1.

10 years agoRevert "Document support for VPATH builds of extensions."
Peter Eisentraut [Tue, 8 Oct 2013 02:42:52 +0000 (22:42 -0400)]
Revert "Document support for VPATH builds of extensions."

This reverts commit 9598134e3030a883ff6eea8a822466ce5143ffeb.

10 years agoRevert "Backpatch pgxs vpath build and installation fixes."
Peter Eisentraut [Tue, 8 Oct 2013 02:32:04 +0000 (22:32 -0400)]
Revert "Backpatch pgxs vpath build and installation fixes."

This reverts commit f8110c5f66ad079e3dbc0b66bed06207c43643ef.

pending resolution of
http://www.postgresql.org/message-id/1381193255.25702.4.camel@vanquo.pezone.net

10 years agoRevert "Ensure installation dirs are built before contents are installed (v2)"
Peter Eisentraut [Tue, 8 Oct 2013 02:31:31 +0000 (22:31 -0400)]
Revert "Ensure installation dirs are built before contents are installed (v2)"

This reverts commit 7f165f2587f6dafe7d4d438136dd959ed5610979.

pending resolution of
http://www.postgresql.org/message-id/1381193255.25702.4.camel@vanquo.pezone.net

10 years agodocs: update release notes for 8.4.18, 9.0.14, 9.1.10, 9.2.5, 9.3.1
Bruce Momjian [Tue, 8 Oct 2013 01:35:02 +0000 (21:35 -0400)]
docs:  update release notes for 8.4.18, 9.0.14, 9.1.10, 9.2.5, 9.3.1

10 years agoFix bugs in SSI tuple locking.
Heikki Linnakangas [Mon, 7 Oct 2013 20:57:40 +0000 (23:57 +0300)]
Fix bugs in SSI tuple locking.

1. In heap_hot_search_buffer(), the PredicateLockTuple() call is passed
wrong offset number. heapTuple->t_self is set to the tid of the first
tuple in the chain that's visited, not the one actually being read.

2. CheckForSerializableConflictIn() uses the tuple's t_ctid field
instead of t_self to check for exiting predicate locks on the tuple. If
the tuple was updated, but the updater rolled back, t_ctid points to the
aborted dead tuple.

Reported by Hannu Krosing. Backpatch to 9.1.

10 years agoTranslation updates
Peter Eisentraut [Mon, 7 Oct 2013 20:27:04 +0000 (16:27 -0400)]
Translation updates

10 years agoEliminate xmin from hash tag for predicate locks on heap tuples.
Kevin Grittner [Mon, 7 Oct 2013 19:26:54 +0000 (14:26 -0500)]
Eliminate xmin from hash tag for predicate locks on heap tuples.

If a tuple was frozen while its predicate locks mattered,
read-write dependencies could be missed, resulting in failure to
detect conflicts which could lead to anomalies in committed
serializable transactions.

This field was added to the tag when we still thought that it was
necessary to carry locks forward to a new version of an updated
row.  That was later proven to be unnecessary, which allowed
simplification of the code, but elimination of xmin from the tag
was missed at the time.

Per report and analysis by Heikki Linnakangas.
Backpatch to 9.1.

10 years agoDocument support for VPATH builds of extensions.
Andrew Dunstan [Mon, 7 Oct 2013 03:03:57 +0000 (23:03 -0400)]
Document support for VPATH builds of extensions.

Cédric Villemain and me.

10 years agopg_upgrade doc: link mode additions
Bruce Momjian [Sat, 5 Oct 2013 14:18:02 +0000 (10:18 -0400)]
pg_upgrade doc: link mode additions

Mention that link mode uses less disk space, and uses junction points on
Windows.

Backpatch to 9.3.

10 years agoadd multixact-no-deadlock to schedule
Alvaro Herrera [Fri, 4 Oct 2013 17:25:30 +0000 (14:25 -0300)]
add multixact-no-deadlock to schedule

10 years agoMake some isolationtester specs more complete
Alvaro Herrera [Fri, 4 Oct 2013 17:24:46 +0000 (14:24 -0300)]
Make some isolationtester specs more complete

Also, make sure they pass on all transaction isolation levels.

10 years agoisolationtester: Allow tuples to be returned in more places
Alvaro Herrera [Fri, 4 Oct 2013 13:32:48 +0000 (10:32 -0300)]
isolationtester: Allow tuples to be returned in more places

Previously, isolationtester would forbid returning tuples in
session-specific teardown (but not global teardown), as well as in
global setup.  Allow these places to return tuples, too.

10 years agodoc: Correct psycopg URL
Peter Eisentraut [Thu, 3 Oct 2013 01:33:26 +0000 (21:33 -0400)]
doc: Correct psycopg URL

10 years agoFix copy/paste error
Magnus Hagander [Wed, 2 Oct 2013 14:42:36 +0000 (16:42 +0200)]
Fix copy/paste error

10 years agoRemove broken PGXS code for pg_xlogdump
Alvaro Herrera [Tue, 1 Oct 2013 20:36:15 +0000 (17:36 -0300)]
Remove broken PGXS code for pg_xlogdump

With the PGXS boilerplate in place, pg_xlogdump currently fails with an
ominous error message that certain targets cannot be built because
certain files do not exist.  Remove that and instead throw a quick error
message alerting the user of the actual problem, which should be easier
to diagnose that the statu quo.

Andres Freund

10 years agoAdd missing condition for pg_depend in hstore migration script.
Andrew Dunstan [Mon, 30 Sep 2013 15:33:54 +0000 (11:33 -0400)]
Add missing condition for pg_depend in hstore migration script.

Error noted by Andres Freund.

10 years agoEnsure installation dirs are built before contents are installed (v2)
Andrew Dunstan [Mon, 30 Sep 2013 14:17:30 +0000 (10:17 -0400)]
Ensure installation dirs are built before contents are installed (v2)

Push dependency on installdirs down to individual targets.

Christoph Berg

10 years agoFix snapshot leak if lo_open called on non-existent object.
Heikki Linnakangas [Mon, 30 Sep 2013 08:29:09 +0000 (11:29 +0300)]
Fix snapshot leak if lo_open called on non-existent object.

lo_open registers the currently active snapshot, and checks if the
large object exists after that. Normally, snapshots registered by lo_open
are unregistered at end of transaction when the lo descriptor is closed, but
if we error out before the lo descriptor is added to the list of open
descriptors, it is leaked. Fix by moving the snapshot registration to after
checking if the large object exists.

Reported by Pavel Stehule. Backpatch to 8.4. The snapshot registration
system was introduced in 8.4, so prior versions are not affected (and not
supported, anyway).

10 years agoFix makefile broken by hstore fix.
Andrew Dunstan [Mon, 30 Sep 2013 02:46:30 +0000 (22:46 -0400)]
Fix makefile broken by hstore fix.

10 years agoUse a new hstore extension version for added json functions.
Andrew Dunstan [Sun, 29 Sep 2013 21:41:56 +0000 (17:41 -0400)]
Use a new hstore extension version for added json functions.

This should have been done when the json functionality was added to
hstore in 9.3.0. To handle this correctly, the upgrade script therefore
uses conditional logic by using plpgsql in a DO statement to add the two
new functions and the new cast. If hstore_to_json_loose is detected as
already present and dependent on the hstore extension nothing is done.
This will require that the database be loaded with plpgsql.

People who have installed the earlier and spurious 1.1 version of hstore
will need to do:

ALTER EXTENSION hstore UPDATE;

to pick up the new functions properly.

10 years agoBackpatch pgxs vpath build and installation fixes.
Andrew Dunstan [Sun, 29 Sep 2013 21:28:16 +0000 (17:28 -0400)]
Backpatch pgxs vpath build and installation fixes.

This is a backpatch of commits d942f9d982b01026, and 6697aa2bc, back
to release 9.1 where we introduced extensions which make heavy use of
the PGXS infrastructure.

10 years agoFix erroneous statements about multiply specified JSON columns.
Andrew Dunstan [Thu, 26 Sep 2013 21:46:07 +0000 (17:46 -0400)]
Fix erroneous statements about multiply specified JSON columns.

The behaviour in json_populate_record() and json_populate_recordset()
was changed during development but the docs were not.

10 years agoFix spurious warning after vacuuming a page on a table with no indexes.
Heikki Linnakangas [Thu, 26 Sep 2013 08:24:40 +0000 (11:24 +0300)]
Fix spurious warning after vacuuming a page on a table with no indexes.

There is a rare race condition, when a transaction that inserted a tuple
aborts while vacuum is processing the page containing the inserted tuple.
Vacuum prunes the page first, which normally removes any dead tuples, but
if the inserting transaction aborts right after that, the loop after
pruning will see a dead tuple and remove it instead. That's OK, but if the
page is on a table with no indexes, and the page becomes completely empty
after removing the dead tuple (or tuples) on it, it will be immediately
marked as all-visible. That's OK, but the sanity check in vacuum would
throw a warning because it thinks that the page contains dead tuples and
was nevertheless marked as all-visible, even though it just vacuumed away
the dead tuples and so it doesn't actually contain any.

Spotted this while reading the code. It's difficult to hit the race
condition otherwise, but can be done by putting a breakpoint after the
heap_page_prune() call.

Backpatch all the way to 8.4, where this code first appeared.

10 years agoPlug memory leak in range_cmp function.
Heikki Linnakangas [Wed, 25 Sep 2013 13:02:00 +0000 (16:02 +0300)]
Plug memory leak in range_cmp function.

B-tree operators are not allowed to leak memory into the current memory
context. Range_cmp leaked detoasted copies of the arguments. That caused
a quick out-of-memory error when creating an index on a range column.

Reported by Marian Krucina, bug #8468.

10 years agoFix pgindent comment breakage
Alvaro Herrera [Tue, 24 Sep 2013 21:19:14 +0000 (18:19 -0300)]
Fix pgindent comment breakage

10 years agoUse @libdir@ in both of regress/{input,output}/security_label.source
Noah Misch [Mon, 23 Sep 2013 20:00:13 +0000 (16:00 -0400)]
Use @libdir@ in both of regress/{input,output}/security_label.source

Though @libdir@ almost always matches @abs_builddir@ in this context,
the test could only fail if they differed.  Back-patch to 9.1, where the
test was introduced.

Hamid Quddus Akhtar

10 years agodoc: Clarify that file_fdw options require values.
Robert Haas [Mon, 23 Sep 2013 18:57:01 +0000 (14:57 -0400)]
doc: Clarify that file_fdw options require values.

Mike Blackwell and Robert Haas

10 years agoFix SSL deadlock risk in libpq
Stephen Frost [Mon, 23 Sep 2013 12:33:41 +0000 (08:33 -0400)]
Fix SSL deadlock risk in libpq

In libpq, we set up and pass to OpenSSL callback routines to handle
locking.  When we run out of SSL connections, we try to clean things
up by de-registering the hooks.  Unfortunately, we had a few calls
into the OpenSSL library after these hooks were de-registered during
SSL cleanup which lead to deadlocking.  This moves the thread callback
cleanup to be after all SSL-cleanup related OpenSSL library calls.
I've been unable to reproduce the deadlock with this fix.

In passing, also move the close_SSL call to be after unlocking our
ssl_config mutex when in a failure state.  While it looks pretty
unlikely to be an issue, it could have resulted in deadlocks if we
ended up in this code path due to something other than SSL_new
failing.  Thanks to Heikki for pointing this out.

Back-patch to all supported versions; note that the close_SSL issue
only goes back to 9.0, so that hunk isn't included in the 8.4 patch.

Initially found and reported by Vesa-Matti J Kari; many thanks to
both Heikki and Andres for their help running down the specific
issue and reviewing the patch.

10 years agoFix two timeline handling bugs in pg_receivexlog.
Heikki Linnakangas [Mon, 23 Sep 2013 07:17:52 +0000 (10:17 +0300)]
Fix two timeline handling bugs in pg_receivexlog.

When a timeline history file is fetched from server, it is initially created
with a temporary file name, and renamed to place. However, the temporary
file name was constructed using an uninitialized buffer. Usually that meant
that the file was created in current directory instead of the target, which
usually goes unnoticed, but if the target is on a different filesystem than
the current dir, the rename() would fail. Fix that.

The second issue is that pg_receivexlog would not take .partial files into
account when determining when scanning the target directory for existing
WAL files. If the timeline has switched in the server several times in the
last WAL segment, and pg_receivexlog is restarted, it would choose a too
old starting point. That's not a problem as long as the old WAL segment
exists in the server and can be streamed over, but will cause a failure if
it's not.

Backpatch to 9.3, where this timeline handling code was written.

Analysed by Andrew Gierth, bug #8453, based on a bug report on IRC.

11 years agoRename various "freeze multixact" variables
Alvaro Herrera [Mon, 16 Sep 2013 18:45:00 +0000 (15:45 -0300)]
Rename various "freeze multixact" variables

It seems to make more sense to use "cutoff multixact" terminology
throughout the backend code; "freeze" is associated with replacing of an
Xid with FrozenTransactionId, which is not what we do for MultiXactIds.

Andres Freund
Some adjustments by Álvaro Herrera

11 years agoIgnore interrupts during quickdie().
Noah Misch [Thu, 12 Sep 2013 00:10:15 +0000 (20:10 -0400)]
Ignore interrupts during quickdie().

Once the administrator has called for an immediate shutdown or a backend
crash has triggered a reinitialization, no mere SIGINT or SIGTERM should
change that course.  Such derailment remains possible when the signal
arrives before quickdie() blocks signals.  That being a narrow race
affecting most PostgreSQL signal handlers in some way, leave it for
another patch.  Back-patch this to all supported versions.

11 years agoReturn error if allocation of new element was not possible.
Michael Meskes [Sun, 8 Sep 2013 10:59:43 +0000 (12:59 +0200)]
Return error if allocation of new element was not possible.

Found by Coverity.

11 years agoClose file to no leak file descriptor memory. Found by Coverity.
Michael Meskes [Sun, 8 Sep 2013 10:49:54 +0000 (12:49 +0200)]
Close file to no leak file descriptor memory. Found by Coverity.

11 years agoImprove Range Types and Exclusion Constraints example.
Jeff Davis [Thu, 5 Sep 2013 06:30:27 +0000 (23:30 -0700)]
Improve Range Types and Exclusion Constraints example.

Make the examples self-contained to avoid confusion. Per bug report
8367 from KOIZUMI Satoru.

11 years agoRemove dead URL mention in OSX startup script
Bruce Momjian [Wed, 4 Sep 2013 21:04:12 +0000 (17:04 -0400)]
Remove dead URL mention in OSX startup script

Backpatch to 9.3.

Per suggestion from Gavan Schneider

11 years agoDon't fail for bad GUCs in CREATE FUNCTION with check_function_bodies off.
Tom Lane [Tue, 3 Sep 2013 22:32:23 +0000 (18:32 -0400)]
Don't fail for bad GUCs in CREATE FUNCTION with check_function_bodies off.

The previous coding attempted to activate all the GUC settings specified
in SET clauses, so that the function validator could operate in the GUC
environment expected by the function body.  However, this is problematic
when restoring a dump, since the SET clauses might refer to database
objects that don't exist yet.  We already have the parameter
check_function_bodies that's meant to prevent forward references in
function definitions from breaking dumps, so let's change CREATE FUNCTION
to not install the SET values if check_function_bodies is off.

Authors of function validators were already advised not to make any
"context sensitive" checks when check_function_bodies is off, if indeed
they're checking anything at all in that mode.  But extend the
documentation to point out the GUC issue in particular.

(Note that we still check the SET clauses to some extent; the behavior
with !check_function_bodies is now approximately equivalent to what ALTER
DATABASE/ROLE have been doing for awhile with context-dependent GUCs.)

This problem can be demonstrated in all active branches, so back-patch
all the way.

11 years agoUpdate obsolete comment
Alvaro Herrera [Tue, 3 Sep 2013 20:52:11 +0000 (16:52 -0400)]
Update obsolete comment

11 years agoFix thinko in worker_spi, count(*) returns a bigint. Thanks RhodiumToad
Greg Stark [Tue, 3 Sep 2013 12:27:34 +0000 (13:27 +0100)]
Fix thinko in worker_spi, count(*) returns a bigint. Thanks RhodiumToad

11 years agodocs: Clarify that we also support Solaris versions greater than 10.
Robert Haas [Tue, 3 Sep 2013 15:16:37 +0000 (11:16 -0400)]
docs: Clarify that we also support Solaris versions greater than 10.

MauMau

11 years agoStamp 9.3.0. REL9_3_0
Tom Lane [Mon, 2 Sep 2013 20:53:17 +0000 (16:53 -0400)]
Stamp 9.3.0.

11 years agoUpdate time zone data files to tzdata release 2013d.
Tom Lane [Mon, 2 Sep 2013 19:06:21 +0000 (15:06 -0400)]
Update time zone data files to tzdata release 2013d.

DST law changes in Israel, Morocco, Palestine, Paraguay.
Historical corrections for Macquarie Island.

11 years agoFix relfrozenxid query in docs to include TOAST tables.
Andrew Dunstan [Mon, 2 Sep 2013 18:37:53 +0000 (14:37 -0400)]
Fix relfrozenxid query in docs to include TOAST tables.

The original query ignored TOAST tables which could result in tables
needing a vacuum not being reported.

Backpatch to all live branches.

11 years agoTranslation updates
Peter Eisentraut [Mon, 2 Sep 2013 06:28:21 +0000 (02:28 -0400)]
Translation updates

11 years agoUpdate "Using EXPLAIN" documentation examples using current code.
Tom Lane [Sun, 1 Sep 2013 23:43:02 +0000 (19:43 -0400)]
Update "Using EXPLAIN" documentation examples using current code.

It seems like a good idea to update these examples since some fairly
basic planner behaviors have changed in 9.3; notably that the startup cost
for an indexscan plan node is no longer invariably estimated at 0.00.

11 years agoUpdate 9.3 release notes.
Tom Lane [Sun, 1 Sep 2013 03:53:33 +0000 (23:53 -0400)]
Update 9.3 release notes.

Some corrections, a lot of copy-editing.

Set projected release date as 2013-09-09.

11 years agoImprove regression test for #8410.
Tom Lane [Sat, 31 Aug 2013 01:40:21 +0000 (21:40 -0400)]
Improve regression test for #8410.

The previous version of the query disregarded the result of the MergeAppend
instead of checking its results.

Andres Freund

11 years agoAdd test case for bug #8410.
Tom Lane [Fri, 30 Aug 2013 23:27:40 +0000 (19:27 -0400)]
Add test case for bug #8410.

Per Andres Freund.

11 years agoReset the binary heap in MergeAppend rescans.
Tom Lane [Fri, 30 Aug 2013 23:15:21 +0000 (19:15 -0400)]
Reset the binary heap in MergeAppend rescans.

Failing to do so can cause queries to return wrong data, error out or crash.
This requires adding a new binaryheap_reset() method to binaryheap.c,
but that probably should have been there anyway.

Per bug #8410 from Terje Elde.  Diagnosis and patch by Andres Freund.

11 years agoMake error wording more consistent
Alvaro Herrera [Thu, 29 Aug 2013 16:33:50 +0000 (12:33 -0400)]
Make error wording more consistent

11 years agoUnconditionally use the WSA equivalents of Socket error constants.
Andrew Dunstan [Mon, 26 Aug 2013 18:58:14 +0000 (14:58 -0400)]
Unconditionally use the WSA equivalents of Socket error constants.

This change will only apply to mingw compilers, and has been found
necessary by late versions of the mingw-w64 compiler. It's the same as
what is done elsewhere for the Microsoft compilers.

Backpatch of commit 73838b5251e.

Problem reported by Michael Cronenworth, although not his patch.