Skip to content
Snippets Groups Projects
  1. Feb 12, 2015
    • Tom Lane's avatar
      Fix more memory leaks in failure path in buildACLCommands. · 8b63f894
      Tom Lane authored
      We already had one go at this issue in commit d73b7f97, but we
      failed to notice that buildACLCommands also leaked several PQExpBuffers
      along with a simply malloc'd string.  This time let's try to make the
      fix a bit more future-proof by eliminating the separate exit path.
      
      It's still not exactly critical because pg_dump will curl up and die on
      failure; but since the amount of the potential leak is now several KB,
      it seems worth back-patching as far as 9.2 where the previous fix landed.
      
      Per Coverity, which evidently is smarter than clang's static analyzer.
      8b63f894
  2. Feb 11, 2015
    • Michael Meskes's avatar
      Fixed array handling in ecpg. · 9be9ac42
      Michael Meskes authored
      When ecpg was rewritten to the new protocol version not all variable types
      were corrected. This patch rewrites the code for these types to fix that. It
      also fixes the documentation to correctly tell the status of array handling.
      9be9ac42
    • Tom Lane's avatar
      Fix pg_dump's heuristic for deciding which casts to dump. · 2593c703
      Tom Lane authored
      Back in 2003 we had a discussion about how to decide which casts to dump.
      At the time pg_dump really only considered an object's containing schema
      to decide what to dump (ie, dump whatever's not in pg_catalog), and so
      we chose a complicated idea involving whether the underlying types were to
      be dumped (cf commit a6790ce8).  But users
      are allowed to create casts between built-in types, and we failed to dump
      such casts.  Let's get rid of that heuristic, which has accreted even more
      ugliness since then, in favor of just looking at the cast's OID to decide
      if it's a built-in cast or not.
      
      In passing, also fix some really ancient code that supposed that it had to
      manufacture a dependency for the cast on its cast function; that's only
      true when dumping from a pre-7.3 server.  This just resulted in some wasted
      cycles and duplicate dependency-list entries with newer servers, but we
      might as well improve it.
      
      Per gripes from a number of people, most recently Greg Sabino Mullane.
      Back-patch to all supported branches.
      2593c703
    • Tom Lane's avatar
      Fix GEQO to not assume its join order heuristic always works. · 0d083103
      Tom Lane authored
      Back in commit 400e2c93 I rewrote GEQO's
      gimme_tree function to improve its heuristic for modifying the given tour
      into a legal join order.  In what can only be called a fit of hubris,
      I supposed that this new heuristic would *always* find a legal join order,
      and ripped out the old logic that allowed gimme_tree to sometimes fail.
      
      The folly of this is exposed by bug #12760, in which the "greedy" clumping
      behavior of merge_clump() can lead it into a dead end which could only be
      recovered from by un-clumping.  We have no code for that and wouldn't know
      exactly what to do with it if we did.  Rather than try to improve the
      heuristic rules still further, let's just recognize that it *is* a
      heuristic and probably must always have failure cases.  So, put back the
      code removed in the previous commit to allow for failure (but comment it
      a bit better this time).
      
      It's possible that this code was actually fully correct at the time and
      has only been broken by the introduction of LATERAL.  But having seen this
      example I no longer have much faith in that proposition, so back-patch to
      all supported branches.
      0d083103
  3. Feb 06, 2015
    • Heikki Linnakangas's avatar
      Report WAL flush, not insert, position in replication IDENTIFY_SYSTEM · 2af568c6
      Heikki Linnakangas authored
      When beginning streaming replication, the client usually issues the
      IDENTIFY_SYSTEM command, which used to return the current WAL insert
      position. That's not suitable for the intended purpose of that field,
      however. pg_receivexlog uses it to start replication from the reported
      point, but if it hasn't been flushed to disk yet, it will fail. Change
      IDENTIFY_SYSTEM to report the flush position instead.
      
      Backpatch to 9.1 and above. 9.0 doesn't report any WAL position.
      2af568c6
  4. Feb 04, 2015
  5. Feb 02, 2015
    • Tom Lane's avatar
      Stamp 9.2.10. · 9f20f2fc
      Tom Lane authored
    • Tom Lane's avatar
      Last-minute updates for release notes. · b8f0a57d
      Tom Lane authored
      Add entries for security issues.
      
      Security: CVE-2015-0241 through CVE-2015-0244
      b8f0a57d
    • Heikki Linnakangas's avatar
      Be more careful to not lose sync in the FE/BE protocol. · 289592b2
      Heikki Linnakangas authored
      If any error occurred while we were in the middle of reading a protocol
      message from the client, we could lose sync, and incorrectly try to
      interpret a part of another message as a new protocol message. That will
      usually lead to an "invalid frontend message" error that terminates the
      connection. However, this is a security issue because an attacker might
      be able to deliberately cause an error, inject a Query message in what's
      supposed to be just user data, and have the server execute it.
      
      We were quite careful to not have CHECK_FOR_INTERRUPTS() calls or other
      operations that could ereport(ERROR) in the middle of processing a message,
      but a query cancel interrupt or statement timeout could nevertheless cause
      it to happen. Also, the V2 fastpath and COPY handling were not so careful.
      It's very difficult to recover in the V2 COPY protocol, so we will just
      terminate the connection on error. In practice, that's what happened
      previously anyway, as we lost protocol sync.
      
      To fix, add a new variable in pqcomm.c, PqCommReadingMsg, that is set
      whenever we're in the middle of reading a message. When it's set, we cannot
      safely ERROR out and continue running, because we might've read only part
      of a message. PqCommReadingMsg acts somewhat similarly to critical sections
      in that if an error occurs while it's set, the error handler will force the
      connection to be terminated, as if the error was FATAL. It's not
      implemented by promoting ERROR to FATAL in elog.c, like ERROR is promoted
      to PANIC in critical sections, because we want to be able to use
      PG_TRY/CATCH to recover and regain protocol sync. pq_getmessage() takes
      advantage of that to prevent an OOM error from terminating the connection.
      
      To prevent unnecessary connection terminations, add a holdoff mechanism
      similar to HOLD/RESUME_INTERRUPTS() that can be used hold off query cancel
      interrupts, but still allow die interrupts. The rules on which interrupts
      are processed when are now a bit more complicated, so refactor
      ProcessInterrupts() and the calls to it in signal handlers so that the
      signal handlers always call it if ImmediateInterruptOK is set, and
      ProcessInterrupts() can decide to not do anything if the other conditions
      are not met.
      
      Reported by Emil Lenngren. Patch reviewed by Noah Misch and Andres Freund.
      Backpatch to all supported versions.
      
      Security: CVE-2015-0244
      289592b2
    • Noah Misch's avatar
      Cherry-pick security-relevant fixes from upstream imath library. · d1972da8
      Noah Misch authored
      This covers alterations to buffer sizing and zeroing made between imath
      1.3 and imath 1.20.  Valgrind Memcheck identified the buffer overruns
      and reliance on uninitialized data; their exploit potential is unknown.
      Builds specifying --with-openssl are unaffected, because they use the
      OpenSSL BIGNUM facility instead of imath.  Back-patch to 9.0 (all
      supported versions).
      
      Security: CVE-2015-0243
      d1972da8
    • Noah Misch's avatar
      Fix buffer overrun after incomplete read in pullf_read_max(). · d95ebe0a
      Noah Misch authored
      Most callers pass a stack buffer.  The ensuing stack smash can crash the
      server, and we have not ruled out the viability of attacks that lead to
      privilege escalation.  Back-patch to 9.0 (all supported versions).
      
      Marko Tiikkaja
      
      Security: CVE-2015-0243
      d95ebe0a
    • Bruce Momjian's avatar
      port/snprintf(): fix overflow and do padding · c6c6aa28
      Bruce Momjian authored
      Prevent port/snprintf() from overflowing its local fixed-size
      buffer and pad to the desired number of digits with zeros, even
      if the precision is beyond the ability of the native sprintf().
      port/snprintf() is only used on systems that lack a native
      snprintf().
      
      Reported by Bruce Momjian. Patch by Tom Lane.	Backpatch to all
      supported versions.
      
      Security: CVE-2015-0242
      c6c6aa28
    • Bruce Momjian's avatar
      to_char(): prevent writing beyond the allocated buffer · e09651e9
      Bruce Momjian authored
      Previously very long localized month and weekday strings could
      overflow the allocated buffers, causing a server crash.
      
      Reported and patch reviewed by Noah Misch.  Backpatch to all
      supported versions.
      
      Security: CVE-2015-0241
      e09651e9
    • Bruce Momjian's avatar
      to_char(): prevent accesses beyond the allocated buffer · 5ae3bf1a
      Bruce Momjian authored
      Previously very long field masks for floats could access memory
      beyond the existing buffer allocated to hold the result.
      
      Reported by Andres Freund and Peter Geoghegan.	Backpatch to all
      supported versions.
      
      Security: CVE-2015-0241
      5ae3bf1a
    • Tom Lane's avatar
      Doc: fix syntax description for psql's \setenv. · 611037d5
      Tom Lane authored
      The variable name isn't optional --- looks like a copy-and-paste-o from
      the \set command, where it is.
      
      Dilip Kumar
      611037d5
    • Peter Eisentraut's avatar
      Translation updates · b77b40d8
      Peter Eisentraut authored
      Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
      Source-Git-Hash: 47199c5813321fac9558fe6629fcb48989a28e44
      b77b40d8
    • Peter Eisentraut's avatar
      doc: Improve claim about location of pg_service.conf · 040f5ef5
      Peter Eisentraut authored
      The previous wording claimed that the file was always in /etc, but of
      course this varies with the installation layout.  Write instead that it
      can be found via `pg_config --sysconfdir`.  Even though this is still
      somewhat incorrect because it doesn't account of moved installations, it
      at least conveys that the location depends on the installation.
      040f5ef5
  6. Feb 01, 2015
    • Tom Lane's avatar
      9eadf637
    • Tom Lane's avatar
      Fix documentation of psql's ECHO all mode. · ad48256b
      Tom Lane authored
      "ECHO all" is ignored for interactive input, and has been for a very long
      time, though possibly not for as long as the documentation has claimed the
      opposite.  Fix that, and also note that empty lines aren't echoed, which
      while dubious is another longstanding behavior (it's embedded in our
      regression test files for one thing).  Per bug #12721 from Hans Ginzel.
      
      In HEAD, also improve the code comments in this area, and suppress an
      unnecessary fflush(stdout) when we're not echoing.  That would likely
      be safe to back-patch, but I'll not risk it mere hours before a release
      wrap.
      ad48256b
  7. Jan 31, 2015
  8. Jan 30, 2015
    • Tom Lane's avatar
      Fix Coverity warning about contrib/pgcrypto's mdc_finish(). · a97dfdfd
      Tom Lane authored
      Coverity points out that mdc_finish returns a pointer to a local buffer
      (which of course is gone as soon as the function returns), leaving open
      a risk of misbehaviors possibly as bad as a stack overwrite.
      
      In reality, the only possible call site is in process_data_packets()
      which does not examine the returned pointer at all.  So there's no
      live bug, but nonetheless the code is confusing and risky.  Refactor
      to avoid the issue by letting process_data_packets() call mdc_finish()
      directly instead of going through the pullf_read() API.
      
      Although this is only cosmetic, it seems good to back-patch so that
      the logic in pgp-decrypt.c stays in sync across all branches.
      
      Marko Kreen
      a97dfdfd
    • Stephen Frost's avatar
      Fix BuildIndexValueDescription for expressions · 915290ee
      Stephen Frost authored
      In 804b6b6d we modified
      BuildIndexValueDescription to pay attention to which columns are visible
      to the user, but unfortunatley that commit neglected to consider indexes
      which are built on expressions.
      
      Handle error-reporting of violations of constraint indexes based on
      expressions by not returning any detail when the user does not have
      table-level SELECT rights.
      
      Backpatch to 9.0, as the prior commit was.
      
      Pointed out by Tom.
      915290ee
    • Tom Lane's avatar
      Handle unexpected query results, especially NULLs, safely in connectby(). · 66cc7468
      Tom Lane authored
      connectby() didn't adequately check that the constructed SQL query returns
      what it's expected to; in fact, since commit 08c33c42 it wasn't
      checking that at all.  This could result in a null-pointer-dereference
      crash if the constructed query returns only one column instead of the
      expected two.  Less excitingly, it could also result in surprising data
      conversion failures if the constructed query returned values that were
      not I/O-conversion-compatible with the types specified by the query
      calling connectby().
      
      In all branches, insist that the query return at least two columns;
      this seems like a minimal sanity check that can't break any reasonable
      use-cases.
      
      In HEAD, insist that the constructed query return the types specified by
      the outer query, including checking for typmod incompatibility, which the
      code never did even before it got broken.  This is to hide the fact that
      the implementation does a conversion to text and back; someday we might
      want to improve that.
      
      In back branches, leave that alone, since adding a type check in a minor
      release is more likely to break things than make people happy.  Type
      inconsistencies will continue to work so long as the actual type and
      declared type are I/O representation compatible, and otherwise will fail
      the same way they used to.
      
      Also, in all branches, be on guard for NULL results from the constructed
      query, which formerly would cause null-pointer dereference crashes.
      We now print the row with the NULL but don't recurse down from it.
      
      In passing, get rid of the rather pointless idea that
      build_tuplestore_recursively() should return the same tuplestore that's
      passed to it.
      
      Michael Paquier, adjusted somewhat by me
      66cc7468
  9. Jan 29, 2015
    • Andres Freund's avatar
      Properly terminate the array returned by GetLockConflicts(). · 8251acf2
      Andres Freund authored
      GetLockConflicts() has for a long time not properly terminated the
      returned array. During normal processing the returned array is zero
      initialized which, while not pretty, is sufficient to be recognized as
      a invalid virtual transaction id. But the HotStandby case is more than
      aesthetically broken: The allocated (and reused) array is neither
      zeroed upon allocation, nor reinitialized, nor terminated.
      
      Not having a terminating element means that the end of the array will
      not be recognized and that recovery conflict handling will thus read
      ahead into adjacent memory. Only terminating when hitting memory
      content that looks like a invalid virtual transaction id.  Luckily
      this seems so far not have caused significant problems, besides making
      recovery conflict more expensive.
      
      Discussion: 20150127142713.GD29457@awork2.anarazel.de
      
      Backpatch into all supported branches.
      8251acf2
    • Heikki Linnakangas's avatar
      Fix bug where GIN scan keys were not initialized with gin_fuzzy_search_limit. · 61729e99
      Heikki Linnakangas authored
      When gin_fuzzy_search_limit was used, we could jump out of startScan()
      without calling startScanKey(). That was harmless in 9.3 and below, because
      startScanKey()() didn't do anything interesting, but in 9.4 it initializes
      information needed for skipping entries (aka GIN fast scans), and you
      readily get a segfault if it's not done. Nevertheless, it was clearly wrong
      all along, so backpatch all the way to 9.1 where the early return was
      introduced.
      
      (AFAICS startScanKey() did nothing useful in 9.3 and below, because the
      fields it initialized were already initialized in ginFillScanKey(), but I
      don't dare to change that in a minor release. ginFillScanKey() is always
      called in gingetbitmap() even though there's a check there to see if the
      scan keys have already been initialized, because they never are; ginrescan()
      free's them.)
      
      In the passing, remove unnecessary if-check from the second inner loop in
      startScan(). We already check in the first loop that the condition is true
      for all entries.
      
      Reported by Olaf Gawenda, bug #12694, Backpatch to 9.1 and above, although
      AFAICS it causes a live bug only in 9.4.
      61729e99
  10. Jan 28, 2015
    • Stephen Frost's avatar
      Clean up range-table building in copy.c · 8e36028f
      Stephen Frost authored
      Commit 804b6b6d added the build of a
      range table in copy.c to initialize the EState es_range_table since it
      can be needed in error paths.  Unfortunately, that commit didn't
      appreciate that some code paths might end up not initializing the rte
      which is used to build the range table.
      
      Fix that and clean up a couple others things along the way- build it
      only once and don't explicitly set it on the !is_from path as it
      doesn't make any sense there (cstate is palloc0'd, so this isn't an
      issue from an initializing standpoint either).
      
      The prior commit went back to 9.0, but this only goes back to 9.1 as
      prior to that the range table build happens immediately after building
      the RTE and therefore doesn't suffer from this issue.
      
      Pointed out by Robert.
      8e36028f
    • Stephen Frost's avatar
      Fix column-privilege leak in error-message paths · d49f84b0
      Stephen Frost authored
      While building error messages to return to the user,
      BuildIndexValueDescription, ExecBuildSlotValueDescription and
      ri_ReportViolation would happily include the entire key or entire row in
      the result returned to the user, even if the user didn't have access to
      view all of the columns being included.
      
      Instead, include only those columns which the user is providing or which
      the user has select rights on.  If the user does not have any rights
      to view the table or any of the columns involved then no detail is
      provided and a NULL value is returned from BuildIndexValueDescription
      and ExecBuildSlotValueDescription.  Note that, for key cases, the user
      must have access to all of the columns for the key to be shown; a
      partial key will not be returned.
      
      Back-patch all the way, as column-level privileges are now in all
      supported versions.
      
      This has been assigned CVE-2014-8161, but since the issue and the patch
      have already been publicized on pgsql-hackers, there's no point in trying
      to hide this commit.
      d49f84b0
  11. Jan 27, 2015
    • Tom Lane's avatar
      Fix NUMERIC field access macros to treat NaNs consistently. · 350f1e7a
      Tom Lane authored
      Commit 14534353 arranged to store numeric
      NaN values as short-header numerics, but the field access macros did not
      get the memo: they thought only "SHORT" numerics have short headers.
      
      Most of the time this makes no difference because we don't access the
      weight or dscale of a NaN; but numeric_send does that.  As pointed out
      by Andrew Gierth, this led to fetching uninitialized bytes.
      
      AFAICS this could not have any worse consequences than that; in particular,
      an unaligned stored numeric would have been detoasted by PG_GETARG_NUMERIC,
      so that there's no risk of a fetch off the end of memory.  Still, the code
      is wrong on its own terms, and it's not hard to foresee future changes that
      might expose us to real risks.  So back-patch to all affected branches.
      350f1e7a
  12. Jan 26, 2015
    • Tom Lane's avatar
      Fix volatile-safety issue in dblink's materializeQueryResult(). · 8abd0e2a
      Tom Lane authored
      Some fields of the sinfo struct are modified within PG_TRY and then
      referenced within PG_CATCH, so as with recent patch to async.c, "volatile"
      is necessary for strict POSIX compliance; and that propagates to a couple
      of subroutines as well as materializeQueryResult() itself.  I think the
      risk of actual issues here is probably higher than in async.c, because
      storeQueryResult() is likely to get inlined into materializeQueryResult(),
      leaving the compiler free to conclude that its stores into sinfo fields are
      dead code.
      8abd0e2a
    • Tom Lane's avatar
      Fix volatile-safety issue in pltcl_SPI_execute_plan(). · 3dd084c7
      Tom Lane authored
      The "callargs" variable is modified within PG_TRY and then referenced
      within PG_CATCH, which is exactly the coding pattern we've now found
      to be unsafe.  Marking "callargs" volatile would be problematic because
      it is passed by reference to some Tcl functions, so fix the problem
      by not modifying it within PG_TRY.  We can just postpone the free()
      till we exit the PG_TRY construct, as is already done elsewhere in this
      same file.
      
      Also, fix failure to free(callargs) when exiting on too-many-arguments
      error.  This is only a minor memory leak, but a leak nonetheless.
      
      In passing, remove some unnecessary "volatile" markings in the same
      function.  Those doubtless are there because gcc 2.95.3 whinged about
      them, but we now know that its algorithm for complaining is many bricks
      shy of a load.
      
      This is certainly a live bug with compilers that optimize similarly
      to current gcc, so back-patch to all active branches.
      3dd084c7
    • Tom Lane's avatar
      Fix volatile-safety issue in asyncQueueReadAllNotifications(). · 5c393a0a
      Tom Lane authored
      The "pos" variable is modified within PG_TRY and then referenced
      within PG_CATCH, so for strict POSIX conformance it must be marked
      volatile.  Superficially the code looked safe because pos's address
      was taken, which was sufficient to force it into memory ... but it's
      not sufficient to ensure that the compiler applies updates exactly
      where the program text says to.  The volatility marking has to extend
      into a couple of subroutines too, but I think that's probably a good
      thing because the risk of out-of-order updates is mostly in those
      subroutines not asyncQueueReadAllNotifications() itself.  In principle
      the compiler could have re-ordered operations such that an error could
      be thrown while "pos" had an incorrect value.
      
      It's unclear how real the risk is here, but for safety back-patch
      to all active branches.
      5c393a0a
  13. Jan 24, 2015
    • Tom Lane's avatar
      Replace a bunch more uses of strncpy() with safer coding. · 502e5f9c
      Tom Lane authored
      strncpy() has a well-deserved reputation for being unsafe, so make an
      effort to get rid of nearly all occurrences in HEAD.
      
      A large fraction of the remaining uses were passing length less than or
      equal to the known strlen() of the source, in which case no null-padding
      can occur and the behavior is equivalent to memcpy(), though doubtless
      slower and certainly harder to reason about.  So just use memcpy() in
      these cases.
      
      In other cases, use either StrNCpy() or strlcpy() as appropriate (depending
      on whether padding to the full length of the destination buffer seems
      useful).
      
      I left a few strncpy() calls alone in the src/timezone/ code, to keep it
      in sync with upstream (the IANA tzcode distribution).  There are also a
      few such calls in ecpg that could possibly do with more analysis.
      
      AFAICT, none of these changes are more than cosmetic, except for the four
      occurrences in fe-secure-openssl.c, which are in fact buggy: an overlength
      source leads to a non-null-terminated destination buffer and ensuing
      misbehavior.  These don't seem like security issues, first because no stack
      clobber is possible and second because if your values of sslcert etc are
      coming from untrusted sources then you've got problems way worse than this.
      Still, it's undesirable to have unpredictable behavior for overlength
      inputs, so back-patch those four changes to all active branches.
      502e5f9c
  14. Jan 21, 2015
    • Tom Lane's avatar
      Improve documentation of random() function. · bdde191c
      Tom Lane authored
      Move random() and setseed() to a separate table, to have them grouped
      together. Also add a notice that random() is not cryptographically secure.
      
      Back-patch of commit 75fdcec1 into
      all supported versions, per discussion of the need to document that
      random() is just a wrapper around random(3).
      bdde191c
  15. Jan 20, 2015
    • Tom Lane's avatar
      In pg_regress, remove the temporary installation upon successful exit. · 89b6a19e
      Tom Lane authored
      This results in a very substantial reduction in disk space usage during
      "make check-world", since that sequence involves creation of numerous
      temporary installations.  It should also help a bit in the buildfarm, even
      though the buildfarm script doesn't create as many temp installations,
      because the current script misses deleting some of them; and anyway it
      seems better to do this once in one place rather than expecting that
      script to get it right every time.
      
      In 9.4 and HEAD, also undo the unwise choice in commit b1aebbb6
      to report strerror(errno) after a rmtree() failure.  rmtree has already
      reported that, possibly for multiple failures with distinct errnos; and
      what's more, by the time it returns there is no good reason to assume
      that errno still reflects the last reportable error.  So reporting errno
      here is at best redundant and at worst badly misleading.
      
      Back-patch to all supported branches, so that future revisions of the
      buildfarm script can rely on this behavior.
      89b6a19e
    • Tom Lane's avatar
      Adjust "pgstat wait timeout" message to be a translatable LOG message. · 33b72353
      Tom Lane authored
      Per discussion, change the log level of this message to be LOG not WARNING.
      The main point of this change is to avoid causing buildfarm run failures
      when the stats collector is exceptionally slow to respond, which it not
      infrequently is on some of the smaller/slower buildfarm members.
      
      This change does lose notice to an interactive user when his stats query
      is looking at out-of-date stats, but the majority opinion (not necessarily
      that of yours truly) is that WARNING messages would probably not get
      noticed anyway on heavily loaded production systems.  A LOG message at
      least ensures that the problem is recorded somewhere where bulk auditing
      for the issue is possible.
      
      Also, instead of an untranslated "pgstat wait timeout" message, provide
      a translatable and hopefully more understandable message "using stale
      statistics instead of current ones because stats collector is not
      responding".  The original text was written hastily under the assumption
      that it would never really happen in practice, which we now know to be
      unduly optimistic.
      
      Back-patch to all active branches, since we've seen the buildfarm issue
      in all branches.
      33b72353
  16. Jan 18, 2015
    • Andres Freund's avatar
      Fix use of already freed memory when dumping a database's security label. · 821386ab
      Andres Freund authored
      pg_dump.c:dumDatabase() called ArchiveEntry() with the results of a a
      query that was PQclear()ed a couple lines earlier.
      
      Backpatch to 9.2 where security labels for shared objects where
      introduced.
      821386ab
    • Peter Eisentraut's avatar
      Fix namespace handling in xpath function · c8ef5b1a
      Peter Eisentraut authored
      Previously, the xml value resulting from an xpath query would not have
      namespace declarations if the namespace declarations were attached to
      an ancestor element in the input xml value.  That means the output value
      was not correct XML.  Fix that by running the result value through
      xmlCopyNode(), which produces the correct namespace declarations.
      
      Author: Ali Akbar <the.apaan@gmail.com>
      c8ef5b1a
  17. Jan 16, 2015
    • Heikki Linnakangas's avatar
      Another attempt at fixing Windows Norwegian locale. · 6bf343c6
      Heikki Linnakangas authored
      Previous fix mapped "Norwegian (Bokmål)" locale, which contains a non-ASCII
      character, to the pure ASCII alias "norwegian-bokmal". However, it turns
      out that more recent versions of the CRT library, in particular MSVCR110
      (Visual Studio 2012), changed the behaviour of setlocale() so that if
      you pass "norwegian-bokmal" to setlocale, it returns "Norwegian_Norway".
      
      That meant trouble, when setlocale(..., NULL) first returned
      "Norwegian (Bokmål)_Norway", which we mapped to "norwegian-bokmal_Norway",
      but another call to setlocale(..., "norwegian-bokmal_Norway") returned
      "Norwegian_Norway". That caused PostgreSQL to think that they are different
      locales, and therefore not compatible. That caused initdb to fail at
      CREATE DATABASE.
      
      Older CRT versions seem to accept "Norwegian_Norway" too, so change the
      mapping to return "Norwegian_Norway" instead of "norwegian-bokmal".
      
      Backpatch to 9.2 like the previous attempt. We haven't made a release that
      includes the previous fix yet, so we don't need to worry about changing the
      locale of existing clusters from "norwegian-bokmal" to "Norwegian_Norway".
      (Doing any mapping like this at all requires changing the locale of
      existing databases; the release notes need to include instructions for
      that).
      6bf343c6
    • Noah Misch's avatar
      Update "pg_regress --no-locale" for Darwin and Windows. · 5596432e
      Noah Misch authored
      Commit 894459e5 revealed this option to
      be broken for NLS builds on Darwin, but "make -C contrib/unaccent check"
      and the buildfarm client rely on it.  Fix that configuration by
      redefining the option to imply LANG=C on Darwin.  In passing, use LANG=C
      instead of LANG=en on Windows; since only postmaster startup uses that
      value, testers are unlikely to notice the change.  Back-patch to 9.0,
      like the predecessor commit.
      5596432e
    • Tom Lane's avatar
      Fix use-of-already-freed-memory problem in EvalPlanQual processing. · 0acb32ef
      Tom Lane authored
      Up to now, the "child" executor state trees generated for EvalPlanQual
      rechecks have simply shared the ResultRelInfo arrays used for the original
      execution tree.  However, this leads to dangling-pointer problems, because
      ExecInitModifyTable() is all too willing to scribble on some fields of the
      ResultRelInfo(s) even when it's being run in one of those child trees.
      This trashes those fields from the perspective of the parent tree, because
      even if the generated subtree is logically identical to what was in use in
      the parent, it's in a memory context that will go away when we're done
      with the child state tree.
      
      We do however want to share information in the direction from the parent
      down to the children; in particular, fields such as es_instrument *must*
      be shared or we'll lose the stats arising from execution of the children.
      So the simplest fix is to make a copy of the parent's ResultRelInfo array,
      but not copy any fields back at end of child execution.
      
      Per report from Manuel Kniep.  The added isolation test is based on his
      example.  In an unpatched memory-clobber-enabled build it will reliably
      fail with "ctid is NULL" errors in all branches back to 9.1, as a
      consequence of junkfilter->jf_junkAttNo being overwritten with $7f7f.
      This test cannot be run as-is before that for lack of WITH syntax; but
      I have no doubt that some variant of this problem can arise in older
      branches, so apply the code change all the way back.
      0acb32ef
Loading