Skip to content
Snippets Groups Projects
  1. Nov 25, 2017
    • Tom Lane's avatar
      Avoid formally-undefined use of memcpy() in hstoreUniquePairs(). · ddba3200
      Tom Lane authored
      hstoreUniquePairs() often called memcpy with equal source and destination
      pointers.  Although this is almost surely harmless in practice, it's
      undefined according to the letter of the C standard.  Some versions of
      valgrind will complain about it, and some versions of libc as well
      (cf. commit ad520ec4).  Tweak the code to avoid doing that.
      
      Noted by Tomas Vondra.  Back-patch to all supported versions because
      of the hazard of libc assertions.
      
      Discussion: https://postgr.es/m/bf84d940-90d4-de91-19dd-612e011007f4@fuzzy.cz
      ddba3200
    • Tom Lane's avatar
      Repair failure with SubPlans in multi-row VALUES lists. · 5dc7faa9
      Tom Lane authored
      When nodeValuesscan.c was written, it was impossible to have a SubPlan in
      VALUES --- any sub-SELECT there would have to be uncorrelated and thereby
      would produce an InitPlan instead.  We therefore took a shortcut in the
      logic that throws away a ValuesScan's per-row expression evaluation data
      structures.  This was broken by the introduction of LATERAL however; a
      sub-SELECT containing a lateral reference produces a correlated SubPlan.
      
      The cleanest fix for this would be to give up the optimization of
      discarding the expression eval state.  But that still seems pretty
      unappetizing for long VALUES lists.  It seems to work to just prevent
      the subexpressions from hooking into the ValuesScan node's subPlan
      list, so let's do that and see how well it works.  (If this breaks,
      due to additional connections between the subexpressions and the outer
      query structures, we might consider compromises like throwing away data
      only for VALUES rows not containing SubPlans.)
      
      Per bug #14924 from Christian Duta.  Back-patch to 9.3 where LATERAL
      was introduced.
      
      Discussion: https://postgr.es/m/20171124120836.1463.5310@wrigleys.postgresql.org
      5dc7faa9
    • Tom Lane's avatar
      Improve planner's handling of set-returning functions in grouping columns. · b9fc2d0b
      Tom Lane authored
      Improve query_is_distinct_for() to accept SRFs in the targetlist when
      we can prove distinctness from a DISTINCT clause.  In that case the
      de-duplication will surely happen after SRF expansion, so the proof
      still works.  Continue to punt in the case where we'd try to prove
      distinctness from GROUP BY (or, in the future, source relations).
      To do that, we'd have to determine whether the SRFs were in the
      grouping columns or elsewhere in the tlist, and it still doesn't
      seem worth the trouble.  But this trivial change allows us to
      recognize that "SELECT DISTINCT unnest(foo) FROM ..." produces
      unique-ified output, which seems worth having.
      
      Also, fix estimate_num_groups() to consider the possibility of SRFs in
      the grouping columns.  Its failure to do so was masked before v10 because
      grouping_planner() scaled up plan rowcount estimates by the estimated SRF
      multiplier after performing grouping.  That doesn't happen anymore, which
      is more correct, but it means we need an adjustment in the estimate for
      the number of groups.  Failure to do this leads to an underestimate for
      the number of output rows of subqueries like "SELECT DISTINCT unnest(foo)"
      compared to what 9.6 and earlier estimated, thus breaking plan choices
      in some cases.
      
      Per report from Dmitry Shalashov.  Back-patch to v10 to avoid degraded
      plan choices compared to previous releases.
      
      Discussion: https://postgr.es/m/CAKPeCUGAeHgoh5O=SvcQxREVkoX7UdeJUMj1F5=aBNvoTa+O8w@mail.gmail.com
      b9fc2d0b
  2. Nov 24, 2017
  3. Nov 23, 2017
  4. Nov 21, 2017
  5. Nov 20, 2017
  6. Nov 18, 2017
  7. Nov 17, 2017
  8. Nov 16, 2017
  9. Nov 14, 2017
    • Tom Lane's avatar
      Prevent int128 from requiring more than MAXALIGN alignment. · 619a8c47
      Tom Lane authored
      Our initial work with int128 neglected alignment considerations, an
      oversight that came back to bite us in bug #14897 from Vincent Lachenal.
      It is unsurprising that int128 might have a 16-byte alignment requirement;
      what's slightly more surprising is that even notoriously lax Intel chips
      sometimes enforce that.
      
      Raising MAXALIGN seems out of the question: the costs in wasted disk and
      memory space would be significant, and there would also be an on-disk
      compatibility break.  Nor does it seem very practical to try to allow some
      data structures to have more-than-MAXALIGN alignment requirement, as we'd
      have to push knowledge of that throughout various code that copies data
      structures around.
      
      The only way out of the box is to make type int128 conform to the system's
      alignment assumptions.  Fortunately, gcc supports that via its
      __attribute__(aligned()) pragma; and since we don't currently support
      int128 on non-gcc-workalike compilers, we shouldn't be losing any platform
      support this way.
      
      Although we could have just done pg_attribute_aligned(MAXIMUM_ALIGNOF) and
      called it a day, I did a little bit of extra work to make the code more
      portable than that: it will also support int128 on compilers without
      __attribute__(aligned()), if the native alignment of their 128-bit-int
      type is no more than that of int64.
      
      Add a regression test case that exercises the one known instance of the
      problem, in parallel aggregation over a bigint column.
      
      Back-patch of commit 75180499.  The code known to be affected only exists
      in 9.6 and later, but we do have some stuff using int128 in 9.5, so patch
      back to 9.5.
      
      Discussion: https://postgr.es/m/20171110185747.31519.28038@wrigleys.postgresql.org
      619a8c47
    • Tom Lane's avatar
      Rearrange c.h to create a "compiler characteristics" section. · a8910506
      Tom Lane authored
      Generalize section 1 to handle stuff that is principally about the
      compiler (not libraries), such as attributes, and collect stuff there
      that had been dropped into various other parts of c.h.  Also, push
      all the gettext macros into section 8, so that section 0 is really
      just inclusions rather than inclusions and random other stuff.
      
      The primary goal here is to get pg_attribute_aligned() defined before
      section 3, so that we can use it with int128.  But this seems like good
      cleanup anyway.
      
      This patch just moves macro definitions around, and shouldn't result
      in any changes in generated code.
      
      Back-patch of commit 91aec93e.
      
      Discussion: https://postgr.es/m/20171110185747.31519.28038@wrigleys.postgresql.org
      a8910506
  10. Nov 13, 2017
  11. Nov 12, 2017
  12. Nov 11, 2017
  13. Nov 10, 2017
  14. Nov 09, 2017
  15. Nov 08, 2017
    • Tom Lane's avatar
      Allow --with-bonjour to work with non-macOS implementations of Bonjour. · 58bc9ea0
      Tom Lane authored
      On macOS the relevant functions require no special library, but elsewhere
      we need to pull in libdns_sd.
      
      Back-patch to supported branches.  No docs change since the docs do not
      suggest that this is a Mac-only feature.
      
      Luke Lonergan
      
      Discussion: https://postgr.es/m/2D8331C5-D64F-44C1-8717-63EDC6EAF7EB@brightforge.com
      58bc9ea0
    • Tom Lane's avatar
      Doc: fix erroneous example. · 6c05b815
      Tom Lane authored
      The grammar requires these options to appear the other way 'round.
      
      jotpe@posteo.de
      
      Discussion: https://postgr.es/m/78933bd0-45ce-690e-b832-a328dd1a5567@posteo.de
      6c05b815
    • Tom Lane's avatar
      Fix two violations of the ResourceOwnerEnlarge/Remember protocol. · 442bc416
      Tom Lane authored
      The point of having separate ResourceOwnerEnlargeFoo and
      ResourceOwnerRememberFoo functions is so that resource allocation
      can happen in between.  Doing it in some other order is just wrong.
      
      OpenTemporaryFile() did open(), enlarge, remember, which would leak the
      open file if the enlarge step ran out of memory.  Because fd.c has its own
      layer of resource-remembering, the consequences look like they'd be limited
      to an intratransaction FD leak, but it's still not good.
      
      IncrBufferRefCount() did enlarge, remember, incr-refcount, which would blow
      up if the incr-refcount step ever failed.  It was safe enough when written,
      but since the introduction of PrivateRefCountHash, I think the assumption
      that no error could happen there is pretty shaky.
      
      The odds of real problems from either bug are probably small, but still,
      back-patch to supported branches.
      
      Thomas Munro and Tom Lane, per a comment from Andres Freund
      442bc416
  16. Nov 07, 2017
    • Tom Lane's avatar
      Fix unportable usage of <ctype.h> functions. · e836502d
      Tom Lane authored
      isdigit(), isspace(), etc are likely to give surprising results if passed a
      signed char.  We should always cast the argument to unsigned char to avoid
      that.  Error in commit 63d6b97f, found by buildfarm member gaur.
      Back-patch to 9.3, like that commit.
      e836502d
    • Tom Lane's avatar
      Fix version numbering foulups exposed by 10.1. · 958fe549
      Tom Lane authored
      configure computed PG_VERSION_NUM incorrectly.  (Coulda sworn I tested
      that logic back when, but it had an obvious thinko.)
      
      pg_upgrade had not been taught about the new dispensation with just
      one part in the major version number.
      
      Both things accidentally failed to fail with 10.0, but with 10.1 we
      got the wrong results.
      
      Per buildfarm.
  17. Nov 06, 2017
Loading