1. 13 11月, 2020 1 次提交
    • H
      Make the macro of FAULT_INJECTOR configurable · 4111340a
      Hao Wu 提交于
      Definition FAULT_INJECTOR is hardcoded in a header(pg_config_manual.h)
      file.  Fault injector is useful, but it may introduce some issues in
      production stage, like runtime cost, security problems.  It's better
      to enable this feature in development and disable it in release.  The
      --enable-debug-extensions configure option is used to control this
      feature.
      4111340a
  2. 17 7月, 2020 1 次提交
    • A
      gporca: Use portable way to get frame address. · 7c1891fb
      Amit Khandekar 提交于
      GPOS_ASMFP() used x86_64 assembly instructions to get current frame
      address. This obviously doesn't compile on other architectures like
      ARM64. So instead use __builtin_frame_address(), which is available
      in gcc and presumably clang. Since gcc and clang are the two most
      common compilers, and since we don't want to support GPORCA on exotic
      architectures and compilers, don't bother to use any other way to get
      the frame address.
      
      Let configure fail if __builtin_frame_address() is not found, but
      don't do this check if gporca is disabled.
      
      GPORCA's CStackDescriptor::Backtrace() uses frame address. But there
      is also gp_backtrace() in the backend code that has similar
      functionality. This commit does not merge these two places. But it
      prepares the infrastructure to do the merge, including a new macro
      HAVE__BUILTIN_FRAME_ADDRESS defined in pg_config.h.
      
      Discussion: https://groups.google.com/a/greenplum.org/forum/#!topic/gpdb-dev/FgaR_4sGYrkReviewed-by: NHeikki Linnakangas <hlinnakangas@pivotal.io>
      7c1891fb
  3. 10 7月, 2020 2 次提交
    • N
      ic-proxy: enable ic-proxy with --enable-ic-proxy · 81810a20
      Ning Yu 提交于
      We used to use the option --with-libuv to enable ic-proxy, it is not
      staightforward to understand the purpose of that option, though.  So we
      renamed it to --enable-ic-proxy, and the default setting is changed to
      "disable".
      
      Suggested by Kris Macoskey <kmacoskey@pivotal.io>
      81810a20
    • N
      ic-proxy: implement the core logic · 6188fb1f
      Ning Yu 提交于
      The interconnect proxy mode, a.k.a. ic-proxy, is a new interconnect
      mode, all the backends communicate via a proxy bgworker, all the
      backends on the same segment share the same proxy bgworker, so every two
      segments only need one network connection between them, which reduces
      the network flows as well the ports.
      
      To enable the proxy mode we need to first configure the guc
      gp_interconnect_proxy_addresses, for example:
      
          gpconfig \
            -c gp_interconnect_proxy_addresses \
            -v "'1:-1:10.0.0.1:2000,2:0:10.0.0.2:2001,3:1:10.0.0.3:2002'" \
            --skipvalidation
      
      Then restart to take effect.
      6188fb1f
  4. 22 5月, 2020 1 次提交
    • C
      Let configure set C++14 mode (#10147) · b371e592
      Chris Hajas 提交于
      Commit 649ee57d "Build ORCA with C++14: Take Two (#10068)" left
      behind a major FIXME: a hard-coded CXXFLAGS in gporca.mk. At the very
      least this looks completely out of place aesthetically. But more
      importantly, this is problematic in several ways:
      
      1. It leaves the language mode for part of the code base
      (src/backend/gpopt "ORCA translator") unspecified. The ORCA translator
      closely collaborates with ORCA and directly uses much of the interfaces
      from ORCA. There is a non-hypothetical risk of non-subtle
      incompatibilities. This is obscured by the fact that GCC and upstream
      Clang (which both default to gnu++14 after their respective 6.0
      releases). Apple Clang from Xcode 11, however, reacts to it much like
      the default is still gnu++98:
      
      > In file included from CConfigParamMapping.cpp:20:
      > In file included from ../../../../src/include/gpopt/config/CConfigParamMapping.h:19:
      > In file included from ../../../../src/backend/gporca/libgpos/include/gpos/common/CBitSet.h:15:
      > In file included from ../../../../src/backend/gporca/libgpos/include/gpos/common/CDynamicPtrArray.h:15:
      > ../../../../src/backend/gporca/libgpos/include/gpos/common/CRefCount.h:68:24: error: expected ';' at end of declaration list
      >                         virtual ~CRefCount() noexcept(false)
      >                                             ^
      >                                             ;
      
      2. It potentially conflicts with other parts of the code base. Namely,
      when configured with gpcloud, we might have -std=c++11 and -std=gnu++14
      in the same breath, which is highly undesirable or an outright error.
      
      3. Idiomatically language standard selection should modify CXX, not
      CXXFLAGS, in the same vein as how AC_PROC_CC_C99 modifies CC.
      
      We already had a precedence of setting the compiler up in C++11 mode
      (albeit for a less-used component gpcloud). This patch leverages the
      same mechanism to set up CXX in C++14 mode.
      Authored-by: NChris Hajas <chajas@pivotal.io>
      b371e592
  5. 08 4月, 2020 1 次提交
    • C
      Fix configure and cmake to build ORCA with debug · 3f3f4a57
      Chris Hajas 提交于
      Previously, we used a config file that was modified by cmake. Instead,
      use configure to modify macros. Additionally use a compile definition in
      cmake so we don't need a separate config file in gpos.
      
      This also enables compile-time warnings in the src/backend/gporca files. C++ files
      in the translator never had these warnings enabled, and so are not
      enabled in src/backend/gpopt. A block of unused code is removed to get
      pass the compile warnings.
      3f3f4a57
  6. 23 3月, 2020 2 次提交
    • H
      Revert "Make fault injector configurable (#9532)" (#9795) · 495343e1
      Hao Wu 提交于
      This reverts commit 7f5c7da1.
      495343e1
    • H
      Make fault injector configurable (#9532) · 7f5c7da1
      Hao Wu 提交于
      Definition FAULT_INJECTOR is hardcoded in a header(pg_config_manual.h) file.
      Fault injector is useful, but it may introduce some issues in production
      stage, like runtime cost, security problems. It's better to enable this
      feature in development and disable it in release.
      
      To achieve this target, we add a configure option to make fault injector
      configurable. When fault injector is disabled, some tests using this feature
      should be avoided to run ICW. Under isolation2 and regress, there are a lot of
      tests. Now, all tests under isolation2 and regress that depend on fault injector
      are moved to a new schedule file. The pattern name of it is XXX_faultinjector_schedule.
      
      **NOTE**
      All tests that depend on fault injector are saved to the XXX_faultinjector_schedule.
      With this rule, we only run tests that don't depend on fault injector when fault injector
      is disabled.
      
      The schedule files used for fault injector are:
      src/test/regress/greenplum_faultinjector_schedule
      src/test/isolation2/isolation2_faultinjector_schedule
      src/test/isolation2/isolation2_resgroup_faultinjector_schedule
      Reviewed-by: NAsim R P <apraveen@pivotal.io>
      Reviewed-by: NAshwin Agrawal <aagrawal@pivotal.io>
      7f5c7da1
  7. 23 1月, 2020 1 次提交
  8. 04 11月, 2019 1 次提交
  9. 31 8月, 2019 1 次提交
  10. 29 8月, 2019 1 次提交
  11. 19 8月, 2019 1 次提交
  12. 09 8月, 2019 1 次提交
  13. 27 6月, 2019 1 次提交
  14. 02 5月, 2019 1 次提交
  15. 18 4月, 2019 1 次提交
    • A
      Remove the --enable-testutils config option and code. · ba66a4a9
      Ashwin Agrawal 提交于
      Compilation with --enable-testutils seems to has been broken long time
      as `MaxDynamicLWLock` is no more defined. Given no one complained
      seems this is unused config option and code. Hence, instead of fixing
      the compilation ripping out this code.
      ba66a4a9
  16. 16 2月, 2019 2 次提交
    • T
      Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. · 02a6a54e
      Tom Lane 提交于
      Test for the compiler builtins __builtin_clz, __builtin_ctz, and
      __builtin_popcount, and make use of these in preference to
      handwritten C code if they're available.  Create src/port
      infrastructure for "leftmost one", "rightmost one", and "popcount"
      so as to centralize these decisions.
      
      On x86_64, __builtin_popcount generally won't make use of the POPCNT
      opcode because that's not universally supported yet.  Provide code
      that checks CPUID and then calls POPCNT via asm() if available.
      This requires indirecting through a function pointer, which is
      an annoying amount of overhead for a one-instruction operation,
      but it's probably not worth working harder than this for our
      current use-cases.
      
      I'm not sure we've found all the existing places that could profit
      from this new infrastructure; but we at least touched all the
      ones that used copied-and-pasted versions of the bitmapset.c code,
      and got rid of multiple copies of the associated constant arrays.
      
      While at it, replace c-compiler.m4's one-per-builtin-function
      macros with a single one that can handle all the cases we need
      to worry about so far.  Also, because I'm paranoid, make those
      checks into AC_LINK checks rather than just AC_COMPILE; the
      former coding failed to verify that libgcc has support for the
      builtin, in cases where it's not inline code.
      
      David Rowley, Thomas Munro, Alvaro Herrera, Tom Lane
      
      Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com
      02a6a54e
    • A
      Revert attempts to use POPCNT etc instructions · 457aef0f
      Alvaro Herrera 提交于
      This reverts commits fc6c7274, 109de05c, d0b4663c and
      711bab1e.
      
      Somebody will have to try harder before submitting this patch again.
      I've spent entirely too much time on it already, and the #ifdef maze yet
      to be written in order for it to build at all got on my nerves.  The
      amount of work needed to get a platform-specific performance improvement
      that's barely above the noise level is not worth it.
      457aef0f
  17. 14 2月, 2019 2 次提交
    • A
      Fix portability issues in pg_bitutils · 109de05c
      Alvaro Herrera 提交于
      We were using uint64 function arguments as "long int" arguments to
      compiler builtins, which fails on machines where long ints are 32 bits:
      the upper half of the uint64 was being ignored.  Fix by using the "ll"
      builtin variants instead, which on those machines take 64 bit arguments.
      
      Also, remove configure tests for __builtin_popcountl() (as well as
      "long" variants for ctz and clz): the theory here is that any compiler
      version will provide all widths or none, so one test suffices.  Were
      this theory to be wrong, we'd have to add tests for
      __builtin_popcountll() and friends, which would be tedious.
      
      Per failures in buildfarm member lapwing and ensuing discussion.
      109de05c
    • A
      Add basic support for using the POPCNT and SSE4.2s LZCNT opcodes · 711bab1e
      Alvaro Herrera 提交于
      These opcodes have been around in the AMD world since 2007, and 2008 in
      the case of intel.  They're supported in GCC and Clang via some __builtin
      macros.  The opcodes may be unavailable during runtime, in which case we
      fall back on a C-based implementation of the code.  In order to get the
      POPCNT instruction we must pass the -mpopcnt option to the compiler.  We
      do this only for the pg_bitutils.c file.
      
      David Rowley (with fragments taken from a patch by Thomas Munro)
      
      Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com
      711bab1e
  18. 13 2月, 2019 1 次提交
    • A
      Use strtof() and not strtod() for float4 input. · f397e085
      Andrew Gierth 提交于
      Using strtod() creates a double-rounding problem; the input decimal
      value is first rounded to the nearest double; rounding that to the
      nearest float may then give an incorrect result.
      
      An example is that 7.038531e-26 when input via strtod and then rounded
      to float4 gives 0xAE43FEp-107 instead of the correct 0xAE43FDp-107.
      
      Values output by earlier PG versions with extra_float_digits=3 should
      all be read in with the same values as previously. However, values
      supplied by other software using shortest representations could be
      mis-read.
      
      On platforms that lack a strtof() entirely, we fall back to the old
      incorrect rounding behavior. (As strtof() is required by C99, such
      platforms are considered of primarily historical interest.) On VS2013,
      some workarounds are used to get correct error handling.
      
      The regression tests now test for the correct input values, so
      platforms that lack strtof() will need resultmap entries. An entry for
      HP-UX 10 is included (more may be needed).
      
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/871s5emitx.fsf@news-spur.riddles.org.uk
      Discussion: https://postgr.es/m/87d0owlqpv.fsf@news-spur.riddles.org.uk
      f397e085
  19. 24 1月, 2019 1 次提交
    • J
      Prevent int128 from requiring more than MAXALIGN alignment. · d74dd56a
      Jesse Zhang 提交于
      We backported 128-bit integer support to speed up aggregates (commits
      8122e143 and 959277a4) from upstream 9.6 into Greenplum (in
      commits 9b164486 and 325e6fcd). However, we forgot to also port a
      follow-up fix postgres/postgres@7518049980b, mostly because it's nuanced
      and hard to reproduce.
      
      There are two ways to tell the brokenness:
      
      1. On a lucky day, tests would fail on my workstation, but not my laptop (or
         vice versa).
      
      1. If you stare at the generated code for `int8_avg_combine` (and friends),
         you'll notice the compiler uses "aligned" instructions like `movaps` and
         `movdqa` (on AMD64).
      
      Today's my lucky day.
      
      Original commit message from postgres/postgres@7518049980b (by Tom Lane):
      
      > 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.
      
      > This will need to be back-patched, along with the preparatory commit
      > 91aec93e.  But let's see what the buildfarm makes of it first.
      
      > Discussion: https://postgr.es/m/20171110185747.31519.28038@wrigleys.postgresql.org
      
      (cherry picked from commit 75180499)
      d74dd56a
  20. 22 1月, 2019 2 次提交
    • T
      Second try at fixing ecpglib thread-safety problem. · ee27584c
      Tom Lane 提交于
      While Windows (allegedly) has _configthreadlocale() pretty far back,
      it seems MinGW didn't acquire support for that till more recently.
      Fortunately, we can use an autoconf probe on that toolchain,
      instead of guessing whether it's there.  (Hm, I wonder whether Cygwin
      will need this also.)
      
      Per buildfarm.
      
      Discussion: https://postgr.es/m/20190121193512.tdmcnic2yjxlufaw@alap3.anarazel.de
      ee27584c
    • T
      Avoid thread-safety problem in ecpglib. · 8eb4a931
      Tom Lane 提交于
      ecpglib attempts to force the LC_NUMERIC locale to "C" while reading
      server output, to avoid problems with strtod() and related functions.
      Historically it's just issued setlocale() calls to do that, but that
      has major problems if we're in a threaded application.  setlocale()
      itself is not required by POSIX to be thread-safe (and indeed is not,
      on recent OpenBSD).  Moreover, its effects are process-wide, so that
      we could cause unexpected results in other threads, or another thread
      could change our setting.
      
      On platforms having uselocale(), which is required by POSIX:2008,
      we can avoid these problems by using uselocale() instead.  Windows
      goes its own way as usual, but we can make it safe by using
      _configthreadlocale().  Platforms having neither continue to use the
      old code, but that should be pretty much nobody among current systems.
      
      This should get back-patched, but let's see what the buildfarm
      thinks of it first.
      
      Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa.
      
      Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us
      8eb4a931
  21. 19 1月, 2019 1 次提交
  22. 11 1月, 2019 1 次提交
  23. 01 1月, 2019 1 次提交
    • M
      Remove configure switch --disable-strong-random · 1707a0d2
      Michael Paquier 提交于
      This removes a portion of infrastructure introduced by fe0a0b59 to allow
      compilation of Postgres in environments where no strong random source is
      available, meaning that there is no linking to OpenSSL and no
      /dev/urandom (Windows having its own CryptoAPI).  No systems shipped
      this century lack /dev/urandom, and the buildfarm is actually not
      testing this switch at all, so just remove it.  This simplifies
      particularly some backend code which included a fallback implementation
      using shared memory, and removes a set of alternate regression output
      files from pgcrypto.
      
      Author: Michael Paquier
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/20181230063219.GG608@paquier.xyz
      1707a0d2
  24. 18 12月, 2018 1 次提交
  25. 17 12月, 2018 1 次提交
    • T
      Modernize our code for looking up descriptive strings for Unix signals. · a73d0831
      Tom Lane 提交于
      At least as far back as the 2008 spec, POSIX has defined strsignal(3)
      for looking up descriptive strings for signal numbers.  We hadn't gotten
      the word though, and were still using the crufty old sys_siglist array,
      which is in no standard even though most Unixen provide it.
      
      Aside from not being formally standards-compliant, this was just plain
      ugly because it involved #ifdef's at every place using the code.
      
      To eliminate the #ifdef's, create a portability function pg_strsignal,
      which wraps strsignal(3) if available and otherwise falls back to
      sys_siglist[] if available.  The set of Unixen with neither API is
      probably empty these days, but on any platform with neither, you'll
      just get "unrecognized signal".  All extant callers print the numeric
      signal number too, so no need to work harder than that.
      
      Along the way, upgrade pg_basebackup's child-error-exit reporting
      to match the rest of the system.
      
      Discussion: https://postgr.es/m/25758.1544983503@sss.pgh.pa.us
      a73d0831
  26. 07 12月, 2018 1 次提交
    • D
      Remove alert sending support via email and SNMP · 65822b80
      Daniel Gustafsson 提交于
      The support for sending alerts via Email or SNMP was quite a kludge,
      and there are much better external tools for managing alerts than
      what we can supply in core anyways so this retires the capability.
      
      All references to alert sending in the docs are removed, but there
      needs to be section written about how to migrate off this feature
      in the release notes or a similar location.
      
      Discussion: https://github.com/greenplum-db/gpdb/pull/6384
      65822b80
  27. 08 11月, 2018 2 次提交
    • T
      Fix inadequate autoconfiscation of copyfile() usage. · c3e6d5d3
      Tom Lane 提交于
      Per buildfarm, HAVE_COPYFILE is not the same thing as HAVE_COPYFILE_H.
      Add the extra configure test.
      c3e6d5d3
    • P
      pg_upgrade: Allow use of file cloning · 3a769d82
      Peter Eisentraut 提交于
      Add another transfer mode --clone to pg_upgrade (besides the existing
      --link and the default copy), using special file cloning calls.  This
      makes the file transfer faster and more space efficient, achieving
      speed similar to --link mode without the associated drawbacks.
      
      On Linux, file cloning is supported on Btrfs and XFS (if formatted with
      reflink support).  On macOS, file cloning is supported on APFS.
      Reviewed-by: NMichael Paquier <michael@paquier.xyz>
      3a769d82
  28. 07 11月, 2018 1 次提交
  29. 09 10月, 2018 1 次提交
    • T
      Select appropriate PG_PRINTF_ATTRIBUTE for recent NetBSD. · aed9fa0b
      Tom Lane 提交于
      NetBSD-current generates a large number of warnings about "%m" not
      being appropriate to use with *printf functions.  While that's true
      for their native printf, it's surely not true for snprintf.c, so I
      think they have misunderstood gcc's definition of the "gnu_printf"
      archetype.  Nonetheless, choosing "__syslog__" instead silences the
      warnings; so teach configure about that.
      
      Since this is only a cosmetic warning issue (and anyway it depends
      on previous hacking to be self-consistent), no back-patch.
      
      Discussion: https://postgr.es/m/16785.1539046036@sss.pgh.pa.us
      aed9fa0b
  30. 03 10月, 2018 1 次提交
    • T
      Make assorted performance improvements in snprintf.c. · abd9ca37
      Tom Lane 提交于
      In combination, these changes make our version of snprintf as fast
      or faster than most platforms' native snprintf, except for cases
      involving floating-point conversion (which we still delegate to
      the native sprintf).  The speed penalty for a float conversion
      is down to around 10% though, much better than before.
      
      Notable changes:
      
      * Rather than always parsing the format twice to see if it contains
      instances of %n$, do the extra scan only if we actually find a $.
      This obviously wins for non-localized formats, and even when there
      is use of %n$, we can avoid scanning text before the first % twice.
      
      * Use strchrnul() if available to find the next %, and emit the
      literal text between % escapes as strings rather than char-by-char.
      
      * Create a bespoke function (dopr_outchmulti) for the common case
      of emitting N copies of the same character, in place of writing
      loops around dopr_outch.
      
      * Simplify construction of the format string for invocations of sprintf
      for floats.
      
      * Const-ify some internal functions, and avoid unnecessary use of
      pass-by-reference arguments.
      
      Patch by me, reviewed by Andres Freund
      
      Discussion: https://postgr.es/m/11787.1534530779@sss.pgh.pa.us
      abd9ca37
  31. 01 10月, 2018 1 次提交
    • T
      Fix detection of the result type of strerror_r(). · e5baf8c2
      Tom Lane 提交于
      The method we've traditionally used, of redeclaring strerror_r() to
      see if the compiler complains of inconsistent declarations, turns out
      not to work reliably because some compilers only report a warning,
      not an error.  Amazingly, this has gone undetected for years, even
      though it certainly breaks our detection of whether strerror_r
      succeeded.
      
      Let's instead test whether the compiler will take the result of
      strerror_r() as a switch() argument.  It's possible this won't
      work universally either, but it's the best idea I could come up with
      on the spur of the moment.
      
      Back-patch of commit 751f532b.  Buildfarm results indicate that only
      icc-on-Linux actually has an issue here; perhaps the lack of field
      reports indicates that people don't build PG for production that way.
      
      Discussion: https://postgr.es/m/10877.1537993279@sss.pgh.pa.us
      e5baf8c2
  32. 27 9月, 2018 2 次提交
    • T
      Try another way to detect the result type of strerror_r(). · 751f532b
      Tom Lane 提交于
      The method we've traditionally used, of redeclaring strerror_r() to
      see if the compiler complains of inconsistent declarations, turns out
      not to work reliably because some compilers only report a warning,
      not an error.  Amazingly, this has gone undetected for years, even
      though it certainly breaks our detection of whether strerror_r
      succeeded.
      
      Let's instead test whether the compiler will take the result of
      strerror_r() as a switch() argument.  It's possible this won't
      work universally either, but it's the best idea I could come up with
      on the spur of the moment.
      
      We should probably back-patch this once the dust settles, but
      first let's see what the buildfarm thinks of it.
      
      Discussion: https://postgr.es/m/10877.1537993279@sss.pgh.pa.us
      751f532b
    • T
      Always use our own versions of *printf(). · 96bf88d5
      Tom Lane 提交于
      We've spent an awful lot of effort over the years in coping with
      platform-specific vagaries of the *printf family of functions.  Let's just
      forget all that mess and standardize on always using src/port/snprintf.c.
      This gets rid of a lot of configure logic, and it will allow a saner
      approach to dealing with %m (though actually changing that is left for
      a follow-on patch).
      
      Preliminary performance testing suggests that as it stands, snprintf.c is
      faster than the native printf functions for some tasks on some platforms,
      and slower for other cases.  A pending patch will improve that, though
      cases with floating-point conversions will doubtless remain slower unless
      we want to put a *lot* of effort into that.  Still, we've not observed
      that *printf is really a performance bottleneck for most workloads, so
      I doubt this matters much.
      
      Patch by me, reviewed by Michael Paquier
      
      Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
      96bf88d5
  33. 26 9月, 2018 1 次提交
    • T
      Convert elog.c's useful_strerror() into a globally-used strerror wrapper. · 26e9d4d4
      Tom Lane 提交于
      elog.c has long had a private strerror wrapper that handles assorted
      possible failures or deficiencies of the platform's strerror.  On Windows,
      it also knows how to translate Winsock error codes, which the native
      strerror does not.  Move all this code into src/port/strerror.c and
      define strerror() as a macro that invokes it, so that both our frontend
      and backend code will have all of this behavior.
      
      I believe this constitutes an actual bug fix on Windows, since AFAICS
      our frontend code did not report Winsock error codes properly before this.
      However, the main point is to lay the groundwork for implementing %m
      in src/port/snprintf.c: the behavior we want %m to have is this one,
      not the native strerror's.
      
      Note that this throws away the prior use of src/port/strerror.c,
      which was to implement strerror() on platforms lacking it.  That's
      been dead code for nigh twenty years now, since strerror() was
      already required by C89.
      
      We should likewise cause strerror_r to use this behavior, but
      I'll tackle that separately.
      
      Patch by me, reviewed by Michael Paquier
      
      Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
      26e9d4d4