1. 17 Feb, 2019 2 commits
  2. 16 Feb, 2019 10 commits
    • Noah Misch's avatar
      Suppress another case of MSVC warning 4146. · faee6fae
      Noah Misch authored
      faee6fae
    • Noah Misch's avatar
      In imath.h, replace stdint.h usage with c.h equivalents. · 04a87ae2
      Noah Misch authored
      As things stood, buildfarm member dory failed.  MSVC versions lacking
      stdint.h are unusable for building PostgreSQL, but pg_config.h.win32
      doesn't know that.  Even so, we support other systems lacking stdint.h,
      including buildfarm member gaur.  Per a suggestion from Tom Lane.
      
      Discussion: https://postgr.es/m/9598.1550353336@sss.pgh.pa.us
      04a87ae2
    • Andrew Gierth's avatar
      Remove float8-small-is-zero regression test variant. · 6ee89952
      Andrew Gierth authored
      Since this was also the variant used as an example in the docs, update
      the docs to use float4-misrounded-input as an example instead, since
      that is now the only remaining variant file.
      6ee89952
    • Noah Misch's avatar
      Import changes from IMath versions (1.3, 1.29]. · 48e24ba6
      Noah Misch authored
      Upstream fixed bugs over the years, but none are confirmed to have
      affected pgcrypto.  We're better off naively tracking upstream than
      reactively maintaining a twelve-year-old snapshot of upstream.  Add a
      header comment describing the synchronization procedure.  Discard use of
      INVERT_COMPARE_RESULT(); the domain of the comparisons in question is
      {-1,0,1}, controlled entirely by code in imath.c.
      
      Andrew Gierth reviewed the Makefile change.  Tom Lane reviewed the
      synchronization procedure description.
      
      Discussion: https://postgr.es/m/20190203035704.GA6226@rfd.leadboat.com
      48e24ba6
    • Noah Misch's avatar
      Fix PERMIT_DECLARATION_AFTER_STATEMENT initialization. · d1299aab
      Noah Misch authored
      The defect caused a mere warning and only for gcc versions before 3.4.0.
      d1299aab
    • Tom Lane's avatar
      Allow user control of CTE materialization, and change the default behavior. · 608b167f
      Tom Lane authored
      Historically we've always materialized the full output of a CTE query,
      treating WITH as an optimization fence (so that, for example, restrictions
      from the outer query cannot be pushed into it).  This is appropriate when
      the CTE query is INSERT/UPDATE/DELETE, or is recursive; but when the CTE
      query is non-recursive and side-effect-free, there's no hazard of changing
      the query results by pushing restrictions down.
      
      Another argument for materialization is that it can avoid duplicate
      computation of an expensive WITH query --- but that only applies if
      the WITH query is called more than once in the outer query.  Even then
      it could still be a net loss, if each call has restrictions that
      would allow just a small part of the WITH query to be computed.
      
      Hence, let's change the behavior for WITH queries that are non-recursive
      and side-effect-free.  By default, we will inline them into the outer
      query (removing the optimization fence) if they are called just once.
      If they are called more than once, we will keep the old behavior by
      default, but the user can override this and force inlining by specifying
      NOT MATERIALIZED.  Lastly, the user can force the old behavior by
      specifying MATERIALIZED; this would mainly be useful when the query had
      deliberately been employing WITH as an optimization fence to prevent a
      poor choice of plan.
      
      Andreas Karlsson, Andrew Gierth, David Fetter
      
      Discussion: https://postgr.es/m/87sh48ffhb.fsf@news-spur.riddles.org.uk
      608b167f
    • Andrew Gierth's avatar
      Fix previous MinGW fix. · 79730e2a
      Andrew Gierth authored
      Definitions required for MinGW need to be outside #if _MSC_VER. Oops.
      79730e2a
    • Michael Meskes's avatar
      Add DECLARE STATEMENT support to ECPG. · bd7c95f0
      Michael Meskes authored
      DECLARE STATEMENT is a statement that lets users declare an identifier
      pointing at a connection.  This identifier will be used in other embedded
      dynamic SQL statement such as PREPARE, EXECUTE, DECLARE CURSOR and so on.
      When connecting to a non-default connection, the AT clause can be used in
      a DECLARE STATEMENT once and is no longer needed in every dynamic SQL
      statement.  This makes ECPG applications easier and more efficient.  Moreover,
      writing code without designating connection explicitly improves portability.
      
      Authors: Ideriha-san ("Ideriha, Takeshi" <ideriha.takeshi@jp.fujitsu.com>)
               Kuroda-san ("Kuroda, Hayato" <kuroda.hayato@jp.fujitsu.com>)
      
      Discussion: https://postgr.es/m4E72940DA2BF16479384A86D54D0988A565669DF@G01JPEXMBKW04
      bd7c95f0
    • Tom Lane's avatar
      Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. · 02a6a54e
      Tom Lane authored
      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
    • Andrew Gierth's avatar
      Cygwin and Mingw floating-point fixes. · 72880ac1
      Andrew Gierth authored
      Deal with silent-underflow errors in float4 for cygwin and mingw by
      using our strtof() wrapper; deal with misrounding errors by adding
      them to the resultmap. Some slight reorganization of declarations was
      done to avoid duplicating material between cygwin.h and win32_port.h.
      
      While here, remove from the resultmap all references to
      float8-small-is-zero; inspection of cygwin output suggests it's no
      longer required there, and the freebsd/netbsd/openbsd entries should
      no longer be necessary (these date back to c. 2000). This commit
      doesn't remove the file itself nor the documentation references for
      it; that will happen in a subsequent commit if all goes well.
      72880ac1
  3. 15 Feb, 2019 8 commits
    • Alvaro Herrera's avatar
      Revert attempts to use POPCNT etc instructions · 457aef0f
      Alvaro Herrera authored
      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
    • Tom Lane's avatar
      Refactor index cost estimation functions in view of IndexClause changes. · e89f14e2
      Tom Lane authored
      Get rid of deconstruct_indexquals() in favor of just iterating over the
      IndexClause list directly.  The extra services that that function used to
      provide, such as hiding clause commutation and associating the right index
      column with each clause, are no longer useful given the new data structure.
      I'd originally thought that it'd provide a useful amount of abstraction
      by freeing callers from paying attention to the exact clause type of each
      indexqual, but that hope proves to have been vain, because few callers can
      ignore the semantic differences between different clause types.  Indeed,
      removing it results in a net code savings, and probably some cycles shaved
      by not having to build an extra list-of-structs data structure.
      
      Also, export a few formerly-static support functions, with the goal
      of allowing extension AMs to write functionality equivalent to
      genericcostestimate() without pointless code duplication.
      
      Discussion: https://postgr.es/m/24586.1550106354@sss.pgh.pa.us
      e89f14e2
    • Alvaro Herrera's avatar
      Fix compiler builtin usage in new pg_bitutils.c · fc6c7274
      Alvaro Herrera authored
      Split out these new functions in three parts: one in a new file that
      uses the compiler builtin and gets compiled with the -mpopcnt compiler
      option if it exists; another one that uses the compiler builtin but not
      the compiler option; and finally the fallback with open-coded
      algorithms.
      
      Split out the configure logic: in the original commit, it was selecting
      to use the -mpopcnt compiler switch together with deciding whether to
      use the compiler builtin, but those two things are really separate.
      Split them out.  Also, expose whether the builtin exists to
      Makefile.global, so that src/port's Makefile can decide whether to
      compile the hw-optimized file.
      
      Remove CPUID test for CTZ/CLZ.  Make pg_{right,left}most_ones use either
      the compiler intrinsic or open-coded algo; trying to use the
      HW-optimized version is a waste of time.  Make them static inline
      functions.
      
      Discussion: https://postgr.es/m/20190213221719.GA15976@alvherre.pgsql
      fc6c7274
    • Peter Eisentraut's avatar
      doc: Update README.links · b060e6c1
      Peter Eisentraut authored
      The guideline to "not use text with <ulink> so the URL appears in
      printed output" is obsolete, since the URL appears as a footnote in
      printed output in that case.
      Reported-by: default avatarChapman Flack <chap@anastigmatix.net>
      Discussion: https://www.postgresql.org/message-id/5C4B1F2F.2000106@anastigmatix.net
      b060e6c1
    • Peter Eisentraut's avatar
      Use standard diff separator for regression.diffs · 8f27a14b
      Peter Eisentraut authored
      Instead of ======..., use the standard separator for a multi-file
      diff, which is, per POSIX,
      
          "diff %s %s %s\n", <diff_options>, <filename1>, <filename2>
      
      This makes regression.diffs behave more like a proper diff file, for
      use with other tools.  And it shows the diff options used, for
      clarity.
      
      Discussion: https://www.postgresql.org/message-id/70440c81-37bb-76dd-e48b-b5a9550d5613@2ndquadrant.com
      8f27a14b
    • Michael Paquier's avatar
      Fix support for CREATE TABLE IF NOT EXISTS AS EXECUTE · 331a613e
      Michael Paquier authored
      The grammar IF NOT EXISTS for CTAS is supported since 9.5 and documented
      as such, however the case of using EXECUTE as query has never been
      covered as EXECUTE CTAS statements and normal CTAS statements are parsed
      separately.
      
      Author: Andreas Karlsson
      Discussion: https://postgr.es/m/2ddcc188-e37c-a0be-32bf-a56b07c3559e@proxel.se
      Backpatch-through: 9.5
      331a613e
    • Thomas Munro's avatar
      Fix race in dsm_attach() when handles are reused. · 6c0fb941
      Thomas Munro authored
      DSM handle values can be reused as soon as the underlying shared memory
      object has been destroyed.  That means that for a brief moment we
      might have two DSM slots with the same handle.  While trying to attach,
      if we encounter a slot with refcnt == 1, meaning that it is currently
      being destroyed, we should continue our search in case the same handle
      exists in another slot.
      
      The race manifested as a rare "dsa_area could not attach to segment"
      error, and was more likely in 10 and 11 due to the lack of distinct
      seed for random() in parallel workers.  It was made very unlikely in
      in master by commit 197e4af9, and older releases don't usually create
      new DSM segments in background workers so it was also unlikely there.
      
      This fixes the root cause of bug report #15585, in which the error
      could also sometimes result in a self-deadlock in the error path.
      It's not yet clear if further changes are needed to avoid that failure
      mode.
      
      Back-patch to 9.4, where dsm.c arrived.
      
      Author: Thomas Munro
      Reported-by: Justin Pryzby, Sergei Kornilov
      Discussion: https://postgr.es/m/20190207014719.GJ29720@telsasoft.com
      Discussion: https://postgr.es/m/15585-324ff6a93a18da46@postgresql.org
      6c0fb941
    • Tom Lane's avatar
      Simplify the planner's new representation of indexable clauses a little. · 8fd3fdd8
      Tom Lane authored
      In commit 1a8d5afb, I thought it'd be a good idea to define
      IndexClause.indexquals as NIL in the most common case where the given
      clause (IndexClause.rinfo) is usable exactly as-is.  It'd be more
      consistent to define the indexquals in that case as being a one-element
      list containing IndexClause.rinfo, but I thought saving the palloc
      overhead for making such a list would be worthwhile.
      
      In hindsight, that was a great example of "premature optimization is the
      root of all evil": it's complicated everyplace that needs to deal with
      the indexquals, requiring duplicative code to handle both the simple
      case and the not-simple case.  I'd initially found that tolerable but
      it's getting less so as I mop up some areas that I'd not touched in
      1a8d5afb.  In any case, two more pallocs during a planner run are
      surely at the noise level (a conclusion confirmed by a bit of
      microbenchmarking).  So let's change this decision before it becomes
      set in stone, and insist that IndexClause.indexquals always be a valid
      list of the actual index quals for the clause.
      
      Discussion: https://postgr.es/m/24586.1550106354@sss.pgh.pa.us
      8fd3fdd8
  4. 14 Feb, 2019 3 commits
  5. 13 Feb, 2019 12 commits
    • Alvaro Herrera's avatar
      Fix portability issues in pg_bitutils · 109de05c
      Alvaro Herrera authored
      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
    • Andrew Gierth's avatar
      Remove a stray subnormal value from float tests. · 80c468b4
      Andrew Gierth authored
      We don't care to assume that input of subnormal float values works,
      but a stray subnormal value from the upstream Ryu regression test had
      been left in the test data by mistake. Remove it.
      
      Per buildfarm member fulmar.
      80c468b4
    • Alvaro Herrera's avatar
      Add -mpopcnt to all compiles of pg_bitutils.c · d0b4663c
      Alvaro Herrera authored
      The way this makefile works, we need to specify it three times.
      d0b4663c
    • Andrew Gierth's avatar
      More float test and portability fixes. · da6520be
      Andrew Gierth authored
      Avoid assuming exact results in tstypes test; some platforms vary.
      (per buildfarm members eulachon, danio, lapwing)
      
      Avoid dubious usage (inherited from upstream) of bool parameters to
      copy_special_str, to see if this fixes the mac/ppc failures (per
      buildfarm members prariedog and locust). (Isolated test programs on a
      ppc mac don't seem to show any other cause that would explain them.)
      da6520be
    • Alvaro Herrera's avatar
      Add basic support for using the POPCNT and SSE4.2s LZCNT opcodes · 711bab1e
      Alvaro Herrera authored
      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
    • Andrew Gierth's avatar
      Fix an overlooked UINT32_MAX. · 754ca993
      Andrew Gierth authored
      Replace with PG_UINT32_MAX. Per buildfarm members dory and woodlouse.
      754ca993
    • Andrew Gierth's avatar
      Change floating-point output format for improved performance. · 02ddd499
      Andrew Gierth authored
      Previously, floating-point output was done by rounding to a specific
      decimal precision; by default, to 6 or 15 decimal digits (losing
      information) or as requested using extra_float_digits. Drivers that
      wanted exact float values, and applications like pg_dump that must
      preserve values exactly, set extra_float_digits=3 (or sometimes 2 for
      historical reasons, though this isn't enough for float4).
      
      Unfortunately, decimal rounded output is slow enough to become a
      noticable bottleneck when dealing with large result sets or COPY of
      large tables when many floating-point values are involved.
      
      Floating-point output can be done much faster when the output is not
      rounded to a specific decimal length, but rather is chosen as the
      shortest decimal representation that is closer to the original float
      value than to any other value representable in the same precision. The
      recently published Ryu algorithm by Ulf Adams is both relatively
      simple and remarkably fast.
      
      Accordingly, change float4out/float8out to output shortest decimal
      representations if extra_float_digits is greater than 0, and make that
      the new default. Applications that need rounded output can set
      extra_float_digits back to 0 or below, and take the resulting
      performance hit.
      
      We make one concession to portability for systems with buggy
      floating-point input: we do not output decimal values that fall
      exactly halfway between adjacent representable binary values (which
      would rely on the reader doing round-to-nearest-even correctly). This
      is known to be a problem at least for VS2013 on Windows.
      
      Our version of the Ryu code originates from
      https://github.com/ulfjack/ryu/ at commit c9c3fb1979, but with the
      following (significant) modifications:
      
       - Output format is changed to use fixed-point notation for small
         exponents, as printf would, and also to use lowercase 'e', a
         minimum of 2 exponent digits, and a mandatory sign on the exponent,
         to keep the formatting as close as possible to previous output.
      
       - The output of exact midpoint values is disabled as noted above.
      
       - The integer fast-path code is changed somewhat (since we have
         fixed-point output and the upstream did not).
      
       - Our project style has been largely applied to the code with the
         exception of C99 declaration-after-statement, which has been
         retained as an exception to our present policy.
      
       - Most of upstream's debugging and conditionals are removed, and we
         use our own configure tests to determine things like uint128
         availability.
      
      Changing the float output format obviously affects a number of
      regression tests. This patch uses an explicit setting of
      extra_float_digits=0 for test output that is not expected to be
      exactly reproducible (e.g. due to numerical instability or differing
      algorithms for transcendental functions).
      
      Conversions from floats to numeric are unchanged by this patch. These
      may appear in index expressions and it is not yet clear whether any
      change should be made, so that can be left for another day.
      
      This patch assumes that the only supported floating point format is
      now IEEE format, and the documentation is updated to reflect that.
      
      Code by me, adapting the work of Ulf Adams and other contributors.
      
      References:
      https://dl.acm.org/citation.cfm?id=3192369
      
      Reviewed-by: Tom Lane, Andres Freund, Donald Dong
      Discussion: https://postgr.es/m/87r2el1bx6.fsf@news-spur.riddles.org.uk
      02ddd499
    • Andrew Gierth's avatar
      Use strtof() and not strtod() for float4 input. · f397e085
      Andrew Gierth authored
      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
    • Peter Eisentraut's avatar
      More unconstify use · 37d99160
      Peter Eisentraut authored
      Replace casts whose only purpose is to cast away const with the
      unconstify() macro.
      
      Discussion: https://www.postgresql.org/message-id/flat/53a28052-f9f3-1808-fed9-460fd43035ab%402ndquadrant.com
      37d99160
    • Peter Eisentraut's avatar
      Remove useless casts · cf40dc65
      Peter Eisentraut authored
      Some of these were uselessly casting away "const", some were just
      nearby, but they where all unnecessary anyway.
      
      Discussion: https://www.postgresql.org/message-id/flat/53a28052-f9f3-1808-fed9-460fd43035ab%402ndquadrant.com
      cf40dc65
    • Michael Paquier's avatar
      Fix comment related to calculation location of total_table_pages · 6ea95166
      Michael Paquier authored
      As of commit c6e4133f, the calculation happens in make_one_rel() and not
      query_planner().
      
      Author: Amit Langote
      Discussion: https://postgr.es/m/c7a04a90-42e6-28a4-811a-a7e352831ba1@lab.ntt.co.jp
      6ea95166
    • Thomas Munro's avatar
      Fix rare dsa_allocate() failures due to freepage.c corruption. · 7215efdc
      Thomas Munro authored
      In a corner case, a btree page was allocated during a clean-up operation
      that could cause the tracking of the largest contiguous span of free
      space to get out of whack.  That was supposed to be prevented by the use
      of the "soft" flag to avoid allocating internal pages during incidental
      clean-up work, but the flag was ignored in the case where the FPM was
      promoted from singleton format to btree format.  Repair.
      
      Remove an obsolete comment in passing.
      
      Back-patch to 10, where freepage.c arrived (as support for dsa.c).
      
      Author: Robert Haas
      Diagnosed-by: Thomas Munro and Robert Haas
      Reported-by: Justin Pryzby, Rick Otten, Sand Stone, Arne Roland and others
      Discussion: https://postgr.es/m/CAMAYy4%2Bw3NTBM5JLWFi8twhWK4%3Dk_5L4nV5%2BbYDSPu8r4b97Zg%40mail.gmail.com
      7215efdc
  6. 12 Feb, 2019 5 commits
    • Tom Lane's avatar
      Clean up planner confusion between ncolumns and nkeycolumns. · 75c46149
      Tom Lane authored
      We're only going to consider key columns when creating indexquals,
      so there is no point in having the outer loops in indxpath.c iterate
      further than nkeycolumns.
      
      Doing so in match_pathkeys_to_index() is actually wrong, and would have
      caused crashes by now, except that we have no index AMs supporting both
      amcanorderbyop and amcaninclude.
      
      It's also wrong in relation_has_unique_index_for().  The effect there is
      to fail to prove uniqueness even when the index does prove it, if there
      are extra columns.
      
      Also future-proof examine_variable() for the day when extra columns can
      be expressions, and fix what's either a thinko or just an oversight in
      btcostestimate(): we should consider the number of key columns, not the
      total, when deciding whether to derate correlation.
      
      None of these things seemed important enough to risk changing in a
      just-before-wrap patch, but since we're past the release wrap window,
      time to fix 'em.
      
      Discussion: https://postgr.es/m/25526.1549847928@sss.pgh.pa.us
      75c46149
    • Alvaro Herrera's avatar
      Relax overly strict assertion · 8c67d29f
      Alvaro Herrera authored
      Ever since its birth, ReorderBufferBuildTupleCidHash() has contained an
      assertion that a catalog tuple cannot change Cmax after acquiring one.  But
      that's wrong: if a subtransaction executes DDL that affects that catalog
      tuple, and later aborts and another DDL affects the same tuple, it will
      change Cmax.  Relax the assertion to merely verify that the Cmax remains
      valid and monotonically increasing, instead.
      
      Add a test that tickles the relevant code.
      
      Diagnosed by, and initial patch submitted by: Arseny Sher
      Co-authored-by: Arseny Sher
      Discussion: https://postgr.es/m/874l9p8hyw.fsf@ars-thinkpad
      8c67d29f
    • Alvaro Herrera's avatar
      Blind attempt at fixing Windows build · d357a169
      Alvaro Herrera authored
      Broken since fe33a196.
      d357a169
    • Alvaro Herrera's avatar
      Use Getopt::Long for catalog scripts · fe33a196
      Alvaro Herrera authored
      Replace hand-rolled option parsing with the Getopt module. This is
      shorter and easier to read. In passing, make some cosmetic adjustments
      for consistency.
      
      Author: John Naylor
      Reviewed-by: David Fetter
      Discussion: https://postgr.es/m/CACPNZCvRjepXh5b2N50njN+rO_2Nzcf=jhMkKX7=79XWUKJyKA@mail.gmail.com
      fe33a196
    • Tom Lane's avatar
      Fix erroneous error reports in snapbuild.c. · 232a8e23
      Tom Lane authored
      It's pretty unhelpful to report the wrong file name in a complaint
      about syscall failure, but SnapBuildSerialize managed to do that twice
      in a span of 50 lines.  Also fix half a dozen missing or poorly-chosen
      errcode assignments; that's mostly cosmetic, but still wrong.
      
      Noted while studying recent failures on buildfarm member nightjar.
      I'm not sure whether those reports are actually giving the wrong
      filename, because there are two places here with identically
      spelled error messages.  The other one is specifically coded not
      to report ENOENT, but if it's this one, how could we be getting
      ENOENT from open() with O_CREAT?  Need to sit back and await results.
      
      However, these ereports are clearly broken from birth, so back-patch.
      232a8e23