Skip to content
Snippets Groups Projects
  1. Nov 24, 2017
  2. 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
  3. Nov 09, 2017
  4. Nov 08, 2017
  5. Nov 07, 2017
  6. Nov 06, 2017
  7. Oct 02, 2017
  8. Sep 25, 2017
    • Tom Lane's avatar
      Avoid SIGBUS on Linux when a DSM memory request overruns tmpfs. · 4621c7f7
      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
      4621c7f7
  9. Sep 18, 2017
  10. Sep 01, 2017
    • Tom Lane's avatar
      Make [U]INT64CONST safe for use in #if conditions. · f2fe1cbe
      Tom Lane authored
      Instead of using a cast to force the constant to be the right width,
      assume we can plaster on an L, UL, LL, or ULL suffix as appropriate.
      The old approach to this is very hoary, dating from before we were
      willing to require compilers to have working int64 types.
      
      This fix makes the PG_INT64_MIN, PG_INT64_MAX, and PG_UINT64_MAX
      constants safe to use in preprocessor conditions, where a cast
      doesn't work.  Other symbolic constants that might be defined using
      [U]INT64CONST are likewise safer than before.
      
      Also fix the SIZE_MAX macro to be similarly safe, if we are forced
      to provide a definition for that.  The test added in commit 2e70d6b5
      happens to do what we want even with the hack "(size_t) -1" definition,
      but we could easily get burnt on other tests in future.
      
      Back-patch to all supported branches, like the previous commits.
      
      Discussion: https://postgr.es/m/15883.1504278595@sss.pgh.pa.us
      f2fe1cbe
  11. Aug 28, 2017
  12. Aug 14, 2017
    • Tom Lane's avatar
      Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant. · 5a5c2fec
      Tom Lane authored
      Commit 3c163a7f's original choice to ignore all #define symbols whose
      names begin with underscore turns out to be too simplistic.  On Windows,
      some Perl installations are built with -D_USE_32BIT_TIME_T, and we must
      absorb that or we get the wrong result for sizeof(PerlInterpreter).
      
      This effectively re-reverts commit ef58b87d, which injected that symbol
      in a hacky way, making it apply to all of Postgres not just PL/Perl.
      More significantly, it did so on *all* 32-bit Windows builds, even when
      the Perl build to be used did not select this option; so that it fails
      to work properly with some newer Perl builds.
      
      By making this change, we would be introducing an ABI break in 32-bit
      Windows builds; but fortunately we have not used type time_t in any
      exported Postgres APIs in a long time.  So it should be OK, both for
      PL/Perl itself and for third-party extensions, if an extension library
      is built with a different _USE_32BIT_TIME_T setting than the core code.
      
      Patch by me, based on research by Ashutosh Sharma and Robert Haas.
      Back-patch to all supported branches, as commit 3c163a7f was.
      
      Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
      5a5c2fec
  13. Aug 11, 2017
  14. Aug 07, 2017
  15. Aug 05, 2017
    • Tom Lane's avatar
      Improve configure's check for ICU presence. · f4f41baf
      Tom Lane authored
      Without ICU's header files, "configure --with-icu" would succeed anyway,
      at least when using the non-pkgconfig-based setup.  Then you got a bunch of
      ugly failures at build.  Add an explicit header check to tighten that up.
      f4f41baf
  16. Aug 01, 2017
    • Tom Lane's avatar
      Further improve consistency of configure's program searching. · b21c569c
      Tom Lane authored
      Peter Eisentraut noted that commit 40b9f192 had broken a configure
      behavior that some people might rely on: AC_CHECK_PROGS(FOO,...) will
      allow the search to be overridden by specifying a value for FOO on
      configure's command line or in its environment, but AC_PATH_PROGS(FOO,...)
      accepts such an override only if it's an absolute path.  We had worked
      around that behavior for some, but not all, of the pre-existing uses
      of AC_PATH_PROGS by just skipping the macro altogether when FOO is
      already set.  Let's standardize on that workaround for all uses of
      AC_PATH_PROGS, new and pre-existing, by wrapping AC_PATH_PROGS in a
      new macro PGAC_PATH_PROGS.  While at it, fix a deficiency of the old
      workaround code by making sure we report the setting to configure's log.
      
      Eventually I'd like to improve PGAC_PATH_PROGS so that it converts
      non-absolute override inputs to absolute form, eg "PYTHON=python3"
      becomes, say, PYTHON = /usr/bin/python3.  But that will take some
      nontrivial coding so it doesn't seem like a thing to do in late beta.
      
      Discussion: https://postgr.es/m/90a92a7d-938e-507a-3bd7-ecd2b4004689@2ndquadrant.com
      b21c569c
  17. Jul 31, 2017
    • Tom Lane's avatar
      Record full paths of programs sought by "configure". · 40b9f192
      Tom Lane authored
      Previously we had a mix of uses of AC_CHECK_PROG[S] and AC_PATH_PROG[S].
      The only difference between those macros is that the latter emits the
      full path to the program it finds, eg "/usr/bin/prove", whereas the
      former emits just "prove".  Let's standardize on always emitting the
      full path; this is better for documentation of the build, and it might
      prevent some types of failures if later build steps are done with
      a different PATH setting.
      
      I did not touch the AC_CHECK_PROG[S] calls in ax_pthread.m4 and
      ax_prog_perl_modules.m4.  There seems no need to make those diverge from
      upstream, since we do not record the programs sought by the former, while
      the latter's call to AC_CHECK_PROG(PERL,...) will never be reached.
      
      Discussion: https://postgr.es/m/25937.1501433410@sss.pgh.pa.us
      40b9f192
  18. Jul 28, 2017
    • Tom Lane's avatar
      PL/Perl portability fix: absorb relevant -D switches from Perl. · 3c163a7f
      Tom Lane authored
      The Perl documentation is very clear that stuff calling libperl should
      be built with the compiler switches shown by Perl's $Config{ccflags}.
      We'd been ignoring that up to now, and mostly getting away with it,
      but recent Perl versions contain ABI compatibility cross-checks that
      fail on some builds because of this omission.  In particular the
      sizeof(PerlInterpreter) can come out different due to some fields being
      added or removed; which means we have a live ABI hazard that we'd better
      fix rather than continuing to sweep it under the rug.
      
      However, it still seems like a bad idea to just absorb $Config{ccflags}
      verbatim.  In some environments Perl was built with a different compiler
      that doesn't even use the same switch syntax.  -D switch syntax is pretty
      universal though, and absorbing Perl's -D switches really ought to be
      enough to fix the problem.
      
      Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
      -D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
      platforms where they're relevant.  Adopting those seems dangerous too.
      It's unclear whether a build wherein Perl and Postgres have different ideas
      of sizeof(off_t) etc would work, or whether anyone would care about making
      it work.  But it's dead certain that having different stdio ABIs in
      core Postgres and PL/Perl will not work; we've seen that movie before.
      Therefore, let's also ignore -D switches for symbols beginning with
      underscore.  The symbols that we actually need to import should be the ones
      mentioned in perl.h's PL_bincompat_options stanza, and none of those start
      with underscore, so this seems likely to work.  (If it turns out not to
      work everywhere, we could consider intersecting the symbols mentioned in
      PL_bincompat_options with the -D switches.  But that will be much more
      complicated, so let's try this way first.)
      
      This will need to be back-patched, but first let's see what the
      buildfarm makes of it.
      
      Ashutosh Sharma, some adjustments by me
      
      Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
      3c163a7f
  19. Jul 10, 2017
  20. Jun 15, 2017
  21. May 15, 2017
  22. Apr 25, 2017
  23. Apr 24, 2017
    • Tom Lane's avatar
      Use pselect(2) not select(2), if available, to wait in postmaster's loop. · 81069a9e
      Tom Lane authored
      Traditionally we've unblocked signals, called select(2), and then blocked
      signals again.  The code expects that the select() will be cancelled with
      EINTR if an interrupt occurs; but there's a race condition, which is that
      an already-pending signal will be delivered as soon as we unblock, and then
      when we reach select() there will be nothing preventing it from waiting.
      This can result in a long delay before we perform any action that
      ServerLoop was supposed to have taken in response to the signal.  As with
      the somewhat-similar symptoms fixed by commit 89390208, the main practical
      problem is slow launching of parallel workers.  The window for trouble is
      usually pretty short, corresponding to one iteration of ServerLoop; but
      it's not negligible.
      
      To fix, use pselect(2) in place of select(2) where available, as that's
      designed to solve exactly this problem.  Where not available, we continue
      to use the old way, and are no worse off than before.
      
      pselect(2) has been required by POSIX since about 2001, so most modern
      platforms should have it.  A bigger portability issue is that some
      implementations are said to be non-atomic, ie pselect() isn't really
      any different from unblock/select/reblock.  Still, we're no worse off
      than before on such a platform.
      
      There is talk of rewriting the postmaster to use a WaitEventSet and
      not do signal response work in signal handlers, at which point this
      could be reverted, since we'd be using a self-pipe to solve the race
      condition.  But that's not happening before v11 at the earliest.
      
      Back-patch to 9.6.  The problem exists much further back, but the
      worst symptom arises only in connection with parallel query, so it
      does not seem worth taking any portability risks in older branches.
      
      Discussion: https://postgr.es/m/9205.1492833041@sss.pgh.pa.us
      81069a9e
    • Andres Freund's avatar
      Don't include sys/poll.h anymore. · b182a4ae
      Andres Freund authored
      poll.h is mandated by Single Unix Spec v2, the usual baseline for
      postgres on unix.  None of the unixoid buildfarms animals has
      sys/poll.h but not poll.h.  Therefore there's not much point to test
      for sys/poll.h's existence and include it optionally.
      
      Author: Andres Freund, per suggestion from Tom Lane
      Discussion: https://postgr.es/m/20505.1492723662@sss.pgh.pa.us
      b182a4ae
  24. Apr 07, 2017
    • Peter Eisentraut's avatar
      Remove use of Jade and DSSSL · 510074f9
      Peter Eisentraut authored
      All documentation is now built using XSLT.  Remove all references to
      Jade, DSSSL, also JadeTex and some other outdated tooling.
      
      For chunked HTML builds, this changes nothing, but removes the
      transitional "oldhtml" target.  The single-page HTML build is ported
      over to XSLT.  For PDF builds, this removes the JadeTex builds and moves
      the FOP builds in their place.
      510074f9
  25. Apr 05, 2017
  26. Mar 29, 2017
    • Peter Eisentraut's avatar
      Fix configure check for typeof · ddce6289
      Peter Eisentraut authored
      ddce6289
    • Peter Eisentraut's avatar
      Cast result of copyObject() to correct type · 4cb82469
      Peter Eisentraut authored
      
      copyObject() is declared to return void *, which allows easily assigning
      the result independent of the input, but it loses all type checking.
      
      If the compiler supports typeof or something similar, cast the result to
      the input type.  This creates a greater amount of type safety.  In some
      cases, where the result is assigned to a generic type such as Node * or
      Expr *, new casts are now necessary, but in general casts are now
      unnecessary in the normal case and indicate that something unusual is
      happening.
      
      Reviewed-by: default avatarMark Dilger <hornschnorter@gmail.com>
      4cb82469
  27. Mar 23, 2017
    • Peter Eisentraut's avatar
      ICU support · eccfef81
      Peter Eisentraut authored
      
      Add a column collprovider to pg_collation that determines which library
      provides the collation data.  The existing choices are default and libc,
      and this adds an icu choice, which uses the ICU4C library.
      
      The pg_locale_t type is changed to a union that contains the
      provider-specific locale handles.  Users of locale information are
      changed to look into that struct for the appropriate handle to use.
      
      Also add a collversion column that records the version of the collation
      when it is created, and check at run time whether it is still the same.
      This detects potentially incompatible library upgrades that can corrupt
      indexes and other structures.  This is currently only supported by
      ICU-provided collations.
      
      initdb initializes the default collation set as before from the `locale
      -a` output but also adds all available ICU locales with a "-x-icu"
      appended.
      
      Currently, ICU-provided collations can only be explicitly named
      collations.  The global database locales are still always libc-provided.
      
      ICU support is enabled by configure --with-icu.
      
      Reviewed-by: default avatarThomas Munro <thomas.munro@enterprisedb.com>
      Reviewed-by: default avatarAndreas Karlsson <andreas@proxel.se>
      eccfef81
  28. Mar 20, 2017
  29. Feb 26, 2017
    • Tom Lane's avatar
      Remove some configure header-file checks that we weren't really using. · 2bd7f857
      Tom Lane authored
      We had some AC_CHECK_HEADER tests that were really wastes of cycles,
      because the code proceeded to #include those headers unconditionally
      anyway, in all or a large majority of cases.  The lack of complaints
      shows that those headers are available on every platform of interest,
      so we might as well let configure run a bit faster by not probing
      those headers at all.
      
      I suspect that some of the tests I left alone are equally useless, but
      since all the existing #includes of the remaining headers are properly
      guarded, I didn't touch them.
      2bd7f857
  30. Feb 23, 2017
    • Tom Lane's avatar
      De-support floating-point timestamps. · b6aa17e0
      Tom Lane authored
      Per discussion, the time has come to do this.  The handwriting has been
      on the wall at least since 9.0 that this would happen someday, whenever
      it got to be too much of a burden to support the float-timestamp option.
      The triggering factor now is the discovery that there are multiple bugs
      in the code that attempts to implement use of integer timestamps in the
      replication protocol even when the server is built for float timestamps.
      The internal float timestamps leak into the protocol fields in places.
      While we could fix the identified bugs, there's a very high risk of
      introducing more.  Trying to build a wall that would positively prevent
      mixing integer and float timestamps is more complexity than we want to
      undertake to maintain a long-deprecated option.  The fact that these
      bugs weren't found through testing also indicates a lack of interest
      in float timestamps.
      
      This commit disables configure's --disable-integer-datetimes switch
      (it'll still accept --enable-integer-datetimes, though), removes direct
      references to USE_INTEGER_DATETIMES, and removes discussion of float
      timestamps from the user documentation.  A considerable amount of code is
      rendered dead by this, but removing that will occur as separate mop-up.
      
      Discussion: https://postgr.es/m/26788.1487455319@sss.pgh.pa.us
      b6aa17e0
  31. Feb 21, 2017
    • Tom Lane's avatar
      Reject too-old Python versions a bit sooner. · 4e5ce3c1
      Tom Lane authored
      Commit 04aad401 added this check after the search for a Python shared
      library, which seems to me to be a pretty unfriendly ordering.  The
      search might fail for what are basically version-related reasons, and
      in such a case it'd be better to say "your Python is too old" than
      "could not find shared library for Python".
      4e5ce3c1
    • Peter Eisentraut's avatar
      Drop support for Python 2.3 · 04aad401
      Peter Eisentraut authored
      There is no specific reason for this right now, but keeping support for
      old Python versions around indefinitely increases the maintenance
      burden.  The oldest supported Python version is now Python 2.4, which is
      still shipped in RHEL/CentOS 5 by default.
      
      In configure, add a check for the required Python version and give a
      friendly error message for an old version, instead of relying on an
      obscure build error later on.
      04aad401
  32. Feb 06, 2017
  33. Jan 03, 2017
  34. Jan 02, 2017
    • Tom Lane's avatar
      Use clock_gettime(), if available, in instr_time measurements. · 1d63f7d2
      Tom Lane authored
      The advantage of clock_gettime() is that the API allows the result to
      be precise to nanoseconds, not just microseconds as in gettimeofday().
      Now that it's routinely possible to do tens of plan node executions
      in 1us, we really need more precision than gettimeofday() can offer
      for EXPLAIN ANALYZE to accumulate statistics with.
      
      Some research shows that clock_gettime() is available on pretty nearly
      every modern Unix-ish platform, and as far as I have been able to test,
      it has about the same execution time as gettimeofday(), so there's no
      loss in switching over.  (By the same token, this doesn't do anything
      to fix the fact that we really wish clock readings were faster.  But
      there's enough win here to justify changing anyway.)
      
      A small side benefit is that on most platforms, we can use CLOCK_MONOTONIC
      instead of CLOCK_REALTIME and thereby render EXPLAIN impervious to
      concurrent resets of the system clock.  (This means that code must not
      assume that the contents of struct instr_time have any well-defined
      interpretation as timestamps, but really that was true before.)
      
      Some platforms offer nonstandard clock IDs that might be of interest.
      This patch knows we should use CLOCK_MONOTONIC_RAW on macOS, because it
      provides more precision and is faster to read than their CLOCK_MONOTONIC.
      If there turn out to be many more cases where we need special rules, it
      might be appropriate to handle the selection of clock ID in configure,
      but for the moment that doesn't seem worth the trouble.
      
      Discussion: https://postgr.es/m/31856.1400021891@sss.pgh.pa.us
      1d63f7d2
  35. Dec 12, 2016
  36. Dec 07, 2016
Loading