1. 26 Sep, 2017 2 commits
  2. 25 Sep, 2017 3 commits
    • Tom Lane's avatar
      Avoid SIGBUS on Linux when a DSM memory request overruns tmpfs. · 899bd785
      Tom Lane authored
      On Linux, shared memory segments created with shm_open() are backed by
      swap files created in tmpfs.  If the swap file needs to be extended,
      but there's no tmpfs space left, you get a very unfriendly SIGBUS trap.
      To avoid this, force allocation of the full request size when we create
      the segment.  This adds a few cycles, but none that we wouldn't expend
      later anyway, assuming the request isn't hugely bigger than the actual
      need.
      
      Make this code #ifdef __linux__, because (a) there's not currently a
      reason to think the same problem exists on other platforms, and (b)
      applying posix_fallocate() to an FD created by shm_open() isn't very
      portable anyway.
      
      Back-patch to 9.4 where the DSM code came in.
      
      Thomas Munro, per a bug report from Amul Sul
      
      Discussion: https://postgr.es/m/1002664500.12301802.1471008223422.JavaMail.yahoo@mail.yahoo.com
      899bd785
    • Tom Lane's avatar
      Make construct_[md_]array return a valid empty array for zero-size input. · 716ea626
      Tom Lane authored
      If construct_array() or construct_md_array() were given a dimension of
      zero, they'd produce an array that contains no elements but has positive
      dimension.  This violates a general expectation that empty arrays should
      have ndims = 0; in particular, while arrays like this print as empty,
      they don't compare equal to other empty arrays.
      
      Up to now we've expected callers to avoid making such calls and instead
      be careful to call construct_empty_array() if there would be no elements.
      But this has always been an easily missed case, and we've repeatedly had to
      fix callers to do it right.  In bug #14826, Erwin Brandstetter pointed out
      yet another such oversight, in ts_lexize(); and a bit of examination of
      other call sites found at least two more with similar issues.  So let's
      fix the problem centrally and permanently by changing these two functions
      to construct a proper zero-D empty array whenever the array would be empty.
      
      This renders a few explicit calls of construct_empty_array() redundant,
      but the only such place I found that really seemed worth changing was in
      ExecEvalArrayExpr().
      
      Although this fixes some very old bugs, no back-patch: the problem is
      pretty minor and the risk of changing behavior seems to outweigh the
      benefit in stable branches.
      
      Discussion: https://postgr.es/m/20170923125723.1448.39412@wrigleys.postgresql.org
      Discussion: https://postgr.es/m/20570.1506198383@sss.pgh.pa.us
      716ea626
    • Andrew Dunstan's avatar
      Support building with Visual Studio 2017 · f2ab3898
      Andrew Dunstan authored
      Haribabu Kommi, reviewed by Takeshi Ideriha and Christian Ullrich
      
      Backpatch to 9.6
      f2ab3898
  3. 24 Sep, 2017 4 commits
    • Tom Lane's avatar
      Fix assorted infelicities in new SetWALSegSize() function. · 8485a25a
      Tom Lane authored
      * Failure to check for malloc failure (ok, pretty unlikely here, but
      that's not an excuse).
      
      * Leakage of open fd on read error, and of malloc'd buffer always.
      
      * Incorrect assumption that a short read would set errno to zero.
      
      * Failure to adhere to message style conventions (in particular,
      not reporting errno where relevant; using "couldn't open" rather than
      "could not open" is not really in line with project style either).
      
      * Missing newlines on some messages.
      
      Coverity spotted the leak problems; I noticed the rest while
      fixing the leaks.
      8485a25a
    • Peter Eisentraut's avatar
      Allow ICU to use SortSupport on Windows with UTF-8 · 6dda0998
      Peter Eisentraut authored
      There is no reason to ever prevent the use of SortSupport on Windows
      when ICU locales are used.  We previously avoided SortSupport on Windows
      with UTF-8 server encoding and a non C-locale due to restrictions in
      Windows' libc functionality.
      
      This is now considered to be a restriction in one platform's libc
      collation provider, and not a more general platform restriction.
      Reported-by: default avatarPeter Geoghegan <pg@bowt.ie>
      6dda0998
    • Peter Eisentraut's avatar
      doc: Expand user documentation on SCRAM · 9b31c72a
      Peter Eisentraut authored
      Explain more about how the different password authentication methods and
      the password_encryption settings relate to each other, give some
      upgrading advice, and set a better link from the release notes.
      Reviewed-by: default avatarJeff Janes <jeff.janes@gmail.com>
      9b31c72a
    • Peter Eisentraut's avatar
      Fix pg_basebackup test to original intent · 74ca8f9b
      Peter Eisentraut authored
      One test case was meant to check that pg_basebackup does not succeed
      when a slot is specified with -S but WAL streaming is not selected,
      which used to require specifying -X stream.  Since -X stream is the
      default in PostgreSQL 10, this test case no longer covers that meaning,
      but the pg_basebackup invocation happened to fail anyway for the
      unrelated reason that the specified replication slot does not exist.  To
      fix, move the test case to later in the file where the slot does exist,
      and add -X none to the invocation so that it covers the originally meant
      behavior.
      
      extracted from a patch by Michael Banck <michael.banck@credativ.de>
      74ca8f9b
  4. 23 Sep, 2017 7 commits
  5. 22 Sep, 2017 16 commits
  6. 21 Sep, 2017 4 commits
  7. 20 Sep, 2017 4 commits
    • Tom Lane's avatar
      Improve dubious memory management in pg_newlocale_from_collation(). · 7b86c2ac
      Tom Lane authored
      pg_newlocale_from_collation() used malloc() and strdup() directly,
      which is generally not per backend coding style, and it didn't bother
      to check for failure results, but would just SIGSEGV instead.  Also,
      if one of the numerous error checks in the middle of the function
      failed, the already-allocated memory would be leaked permanently.
      Admittedly, it's not a lot of memory, but it could build up if this
      function were called repeatedly for a bad collation.
      
      The first two problems are easily cured by palloc'ing in TopMemoryContext
      instead of calling libc directly.  We can fairly easily dodge the leakage
      problem for the struct pg_locale_struct by filling in a temporary variable
      and allocating permanent storage only once we reach the bottom of the
      function.  It's harder to get rid of the potential leakage for ICU's copy
      of the collcollate string, but at least that's only allocated after most
      of the error checks; so live with that aspect.
      
      Back-patch to v10 where this code came in, with one or another of the
      ICU patches.
      7b86c2ac
    • Tom Lane's avatar
      Fix instability in subscription regression test. · 4939488a
      Tom Lane authored
      005_encoding.pl neglected to wait for the subscriber's initial
      synchronization to happen.  While we have not seen this fail in
      the buildfarm, it's pretty easy to demonstrate there's an issue
      by hacking logicalrep_worker_launch() to fail most of the time.
      
      Michael Paquier
      
      Discussion: https://postgr.es/m/27032.1505749806@sss.pgh.pa.us
      4939488a
    • Tom Lane's avatar
      Fix erroneous documentation about noise word GROUP. · 36b564c6
      Tom Lane authored
      GRANT, REVOKE, and some allied commands allow the noise word GROUP
      before a role name (cf. grantee production in gram.y).  This option
      does not exist elsewhere, but it had nonetheless snuck into the
      documentation for ALTER ROLE, ALTER USER, and CREATE SCHEMA.
      
      Seems to be a copy-and-pasteo in commit 31eae602, which did expand the
      syntax choices here, but not in that way.  Back-patch to 9.5 where that
      came in.
      
      Discussion: https://postgr.es/m/20170916123750.8885.66941@wrigleys.postgresql.org
      36b564c6
    • Robert Haas's avatar
      Fix create_lateral_join_info to handle dead relations properly. · 57eebca0
      Robert Haas authored
      Commit 0a480502 broke it.
      
      Report by Andreas Seltenreich.  Fix by Ashutosh Bapat.
      
      Discussion: http://postgr.es/m/874ls2vrnx.fsf@ansel.ydns.eu
      57eebca0