Skip to content
Snippets Groups Projects
  1. Apr 15, 2017
    • Andrew Dunstan's avatar
      Downcase "Wincrypt.h" · 0eba6be1
      Andrew Dunstan authored
      This is consistent with how we refer to other Windows include files, and
      prevents a failure when cross-compiling on a system with case sensitive
      file names.
      0eba6be1
  2. Mar 17, 2017
    • Heikki Linnakangas's avatar
      Fix and simplify check for whether we're running as Windows service. · ff30aec7
      Heikki Linnakangas authored
      If the process token contains SECURITY_SERVICE_RID, but it has been
      disabled by the SE_GROUP_USE_FOR_DENY_ONLY attribute, win32_is_service()
      would incorrectly report that we're running as a service. That situation
      arises, e.g. if postmaster is launched with a restricted security token,
      with the "Log in as Service" privilege explicitly removed.
      
      Replace the broken code with CheckProcessTokenMembership(), which does
      this correctly. Also replace similar code in win32_is_admin(), even
      though it got this right, for simplicity and consistency.
      
      Per bug #13755, reported by Breen Hagan. Back-patch to all supported
      versions. Patch by Takayuki Tsunakawa, reviewed by Michael Paquier.
      
      Discussion: https://www.postgresql.org/message-id/20151104062315.2745.67143%40wrigleys.postgresql.org
      ff30aec7
  3. Feb 26, 2017
    • Tom Lane's avatar
      Put back #include <windows.h> in dirmod.c. · 285ca261
      Tom Lane authored
      I removed this in commit 9e3755ec, reasoning that the win32.h
      port-specific header file included by c.h would have provided it.
      However, that's only true on native win32 builds, not Cygwin builds.
      
      It may be that some of the other <windows.h> inclusions also need
      to be put back on the same grounds; but this is the only one that
      is clearly meant to be included #ifdef __CYGWIN__, so maybe this is
      the extent of the problem.  Awaiting further buildfarm results.
      285ca261
  4. Feb 25, 2017
    • Tom Lane's avatar
      Remove useless duplicate inclusions of system header files. · 9e3755ec
      Tom Lane authored
      c.h #includes a number of core libc header files, such as <stdio.h>.
      There's no point in re-including these after having read postgres.h,
      postgres_fe.h, or c.h; so remove code that did so.
      
      While at it, also fix some places that were ignoring our standard pattern
      of "include postgres[_fe].h, then system header files, then other Postgres
      header files".  While there's not any great magic in doing it that way
      rather than system headers last, it's silly to have just a few files
      deviating from the general pattern.  (But I didn't attempt to enforce this
      globally, only in files I was touching anyway.)
      
      I'd be the first to say that this is mostly compulsive neatnik-ism,
      but over time it might save enough compile cycles to be useful.
      9e3755ec
  5. Jan 04, 2017
    • Magnus Hagander's avatar
      Attempt to handle pending-delete files on Windows · 9951741b
      Magnus Hagander authored
      These files are deleted but not yet gone from the filesystem. Operations
      on them will return ERROR_DELETE_PENDING.
      
      With this we start treating that as ENOENT, meaning files does not
      exist (which is the state it will soon reach). This should be safe in
      every case except when we try to recreate a file with exactly the same
      name. This is an operation that PostgreSQL does very seldom, so
      hopefully that won't happen much -- and even if it does, this treatment
      should be no worse than treating it as an unhandled error.
      
      We've been un able to reproduce the bug reliably, so pushing this to
      master to get buildfarm coverage and other testing. Once it's proven to
      be stable, it should be considered for backpatching.
      
      Discussion: https://postgr.es/m/20160712083220.1426.58667%40wrigleys.postgresql.org
      
      Patch by me and Michael Paquier
      9951741b
  6. Jan 03, 2017
  7. Dec 05, 2016
    • Heikki Linnakangas's avatar
      Replace PostmasterRandom() with a stronger source, second attempt. · fe0a0b59
      Heikki Linnakangas authored
      This adds a new routine, pg_strong_random() for generating random bytes,
      for use in both frontend and backend. At the moment, it's only used in
      the backend, but the upcoming SCRAM authentication patches need strong
      random numbers in libpq as well.
      
      pg_strong_random() is based on, and replaces, the existing implementation
      in pgcrypto. It can acquire strong random numbers from a number of sources,
      depending on what's available:
      
      - OpenSSL RAND_bytes(), if built with OpenSSL
      - On Windows, the native cryptographic functions are used
      - /dev/urandom
      
      Unlike the current pgcrypto function, the source is chosen by configure.
      That makes it easier to test different implementations, and ensures that
      we don't accidentally fall back to a less secure implementation, if the
      primary source fails. All of those methods are quite reliable, it would be
      pretty surprising for them to fail, so we'd rather find out by failing
      hard.
      
      If no strong random source is available, we fall back to using erand48(),
      seeded from current timestamp, like PostmasterRandom() was. That isn't
      cryptographically secure, but allows us to still work on platforms that
      don't have any of the above stronger sources. Because it's not very secure,
      the built-in implementation is only used if explicitly requested with
      --disable-strong-random.
      
      This replaces the more complicated Fortuna algorithm we used to have in
      pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
      so it doesn't seem worth the maintenance effort to keep that. pgcrypto
      functions that require strong random numbers will be disabled with
      --disable-strong-random.
      
      Original patch by Magnus Hagander, tons of further work by Michael Paquier
      and me.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com
      fe0a0b59
  8. Dec 04, 2016
  9. Dec 03, 2016
    • Noah Misch's avatar
      Make pgwin32_putenv() follow DLL loading and unloading. · 202dbdbe
      Noah Misch authored
      Until now, the first putenv() call of a given postgres.exe process would
      cache the set of loaded CRTs.  If a CRT unloaded after that call, the
      next putenv() would crash.  That risk was largely theoretical, because
      the first putenv() precedes all PostgreSQL-initiated module loading.
      However, this might explain bad interactions with antivirus and other
      software that injects threads asynchronously.  If an additional CRT
      loaded after the first putenv(), pgwin32_putenv() would not discover it.
      That CRT would have all environment changes predating its load, but it
      would not receive later PostgreSQL-initiated changes.  An additional CRT
      loading concurrently with the first putenv() might miss that change in
      addition to missing later changes.  Fix all those problems.  This
      removes the cache mechanism from pgwin32_putenv(); the cost, less than
      100 μs per backend startup, is negligible.
      
      No resulting misbehavior was known to be user-visible given the core
      distribution alone, but one can readily construct an affected extension
      module.  No back-patch given the lack of complaints and the potential
      for behavior changes in non-PostgreSQL code running in the backend.
      
      Christian Ullrich, reviewed by Michael Paquier.
      202dbdbe
    • Noah Misch's avatar
      Make pgwin32_putenv() visit debug CRTs. · 95b9b8a3
      Noah Misch authored
      This has no effect in the most conventional case, where no relevant DLL
      uses a debug build.  For an example where it does matter, given a debug
      build of MIT Kerberos, the krb_server_keyfile parameter usually had no
      effect.  Since nobody wants a Heisenbug, back-patch to 9.2 (all
      supported versions).
      
      Christian Ullrich, reviewed by Michael Paquier.
      95b9b8a3
    • Noah Misch's avatar
      Remove wrong CloseHandle() call. · b37da1e8
      Noah Misch authored
      In accordance with its own documentation, invoke CloseHandle() only when
      directed in the documentation for the function that furnished the
      handle.  GetModuleHandle() does not so direct.  We have been issuing
      this call only in the rare event that a CRT DLL contains no "_putenv"
      symbol, so lack of bug reports is uninformative.  Back-patch to 9.2 (all
      supported versions).
      
      Christian Ullrich, reviewed by Michael Paquier.
      b37da1e8
    • Noah Misch's avatar
      Refine win32env.c cosmetics. · a9d9208c
      Noah Misch authored
      Replace use of plain 0 as a null pointer constant.  In comments, update
      terminology and lessen redundancy.  Back-patch to 9.2 (all supported
      versions) for the convenience of back-patching the next two commits.
      
      Christian Ullrich and Noah Misch, reviewed (in earlier versions) by
      Michael Paquier.
      a9d9208c
  10. Nov 05, 2016
  11. Oct 28, 2016
    • Peter Eisentraut's avatar
      Remove invitation to report a bug about unknown encoding · ce4dc970
      Peter Eisentraut authored
      The error message when we couldn't determine the encoding from a locale
      said to report a bug about that.  That might have been appropriate when
      this code was first added, but by now this works pretty solidly and any
      encodings we don't recognize we probably just don't support.  We still
      print the warning, but no longer invite the bug report.
      ce4dc970
  12. Oct 23, 2016
    • Magnus Hagander's avatar
      Allow pg_basebackup to stream transaction log in tar mode · 56c7d8d4
      Magnus Hagander authored
      This will write the received transaction log into a file called
      pg_wal.tar(.gz) next to the other tarfiles instead of writing it to
      base.tar. When using fetch mode, the transaction log is still written to
      base.tar like before, and when used against a pre-10 server, the file
      is named pg_xlog.tar.
      
      To do this, implement a new concept of a "walmethod", which is
      responsible for writing the WAL. Two implementations exist, one that
      writes to a plain directory (which is also used by pg_receivexlog) and
      one that writes to a tar file with optional compression.
      
      Reviewed by Michael Paquier
      56c7d8d4
  13. Oct 18, 2016
  14. Oct 17, 2016
    • Heikki Linnakangas's avatar
      Replace PostmasterRandom() with a stronger way of generating randomness. · 9e083fd4
      Heikki Linnakangas authored
      This adds a new routine, pg_strong_random() for generating random bytes,
      for use in both frontend and backend. At the moment, it's only used in
      the backend, but the upcoming SCRAM authentication patches need strong
      random numbers in libpq as well.
      
      pg_strong_random() is based on, and replaces, the existing implementation
      in pgcrypto. It can acquire strong random numbers from a number of sources,
      depending on what's available:
      - OpenSSL RAND_bytes(), if built with OpenSSL
      - On Windows, the native cryptographic functions are used
      - /dev/urandom
      - /dev/random
      
      Original patch by Magnus Hagander, with further work by Michael Paquier
      and me.
      
      Discussion: <CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com>
      9e083fd4
  15. Oct 11, 2016
    • Tom Lane's avatar
      Remove "sco" and "unixware" ports. · 2b860f52
      Tom Lane authored
      SCO OpenServer and SCO UnixWare are more or less dead platforms.
      We have never had a buildfarm member testing the "sco" port, and
      the last "unixware" member was last heard from in 2012, so it's
      fair to doubt that the code even compiles anymore on either one.
      Remove both ports.  We can always undo this if someone shows up
      with an interest in maintaining and testing these platforms.
      
      Discussion: <17177.1476136994@sss.pgh.pa.us>
      2b860f52
  16. Sep 27, 2016
    • Alvaro Herrera's avatar
      Include <sys/select.h> where needed · 51c3e9fa
      Alvaro Herrera authored
      <sys/select.h> is required by POSIX.1-2001 to get the prototype of
      select(2), but nearly no systems enforce that because older standards
      let you get away with including some other headers.  Recent OpenBSD
      hacking has removed that frail touch of friendliness, however, which
      broke some compiles; fix all the way back to 9.1 by adding the required
      standard.  Only vacuumdb.c was reported to fail, but it seems easier to
      fix the whole lot in a fell swoop.
      
      Per bug #14334 by Sean Farrell.
      51c3e9fa
  17. Sep 25, 2016
    • Tom Lane's avatar
      Refer to OS X as "macOS", except for the port name which is still "darwin". · da6c4f6c
      Tom Lane authored
      We weren't terribly consistent about whether to call Apple's OS "OS X"
      or "Mac OS X", and the former is probably confusing to people who aren't
      Apple users.  Now that Apple has rebranded it "macOS", follow their lead
      to establish a consistent naming pattern.  Also, avoid the use of the
      ancient project name "Darwin", except as the port code name which does not
      seem desirable to change.  (In short, this patch touches documentation and
      comments, but no actual code.)
      
      I didn't touch contrib/start-scripts/osx/, either.  I suspect those are
      obsolete and due for a rewrite, anyway.
      
      I dithered about whether to apply this edit to old release notes, but
      those were responsible for quite a lot of the inconsistencies, so I ended
      up changing them too.  Anyway, Apple's being ahistorical about this,
      so why shouldn't we be?
      da6c4f6c
  18. Sep 20, 2016
    • Peter Eisentraut's avatar
      Re-add translation markers that were lost · 90c96482
      Peter Eisentraut authored
      When win32security.c was moved from src/backend/port/win32/security.c,
      the message writing function was changed from write_stderr to log_error,
      but nls.mk was not updated.  We could add log_error to GETTEXT_TRIGGERS,
      but it's also used in src/common/exec.c in a different way and that
      would create some confusion or a larger patch.  For now, just put an
      explicit translation marker onto the strings that were previously
      translated.
      90c96482
  19. Aug 30, 2016
    • Tom Lane's avatar
      Simplify correct use of simple_prompt(). · 9daec77e
      Tom Lane authored
      The previous API for this function had it returning a malloc'd string.
      That meant that callers had to check for NULL return, which few of them
      were doing, and it also meant that callers had to remember to free()
      the string later, which required extra logic in most cases.
      
      Instead, make simple_prompt() write into a buffer supplied by the caller.
      Anywhere that the maximum required input length is reasonably small,
      which is almost all of the callers, we can just use a local or static
      array as the buffer instead of dealing with malloc/free.
      
      A fair number of callers used "pointer == NULL" as a proxy for "haven't
      requested the password yet".  Maintaining the same behavior requires
      adding a separate boolean flag for that, which adds back some of the
      complexity we save by removing free()s.  Nonetheless, this nets out
      at a small reduction in overall code size, and considerably less code
      than we would have had if we'd added the missing NULL-return checks
      everywhere they were needed.
      
      In passing, clean up the API comment for simple_prompt() and get rid
      of a very-unnecessary malloc/free in its Windows code path.
      
      This is nominally a bug fix, but it does not seem worth back-patching,
      because the actual risk of an OOM failure in any of these places seems
      pretty tiny, and all of them are client-side not server-side anyway.
      
      This patch is by me, but it owes a great deal to Michael Paquier
      who identified the problem and drafted a patch for fixing it the
      other way.
      
      Discussion: <CAB7nPqRu07Ot6iht9i9KRfYLpDaF2ZuUv5y_+72uP23ZAGysRg@mail.gmail.com>
      9daec77e
  20. Aug 15, 2016
    • Tom Lane's avatar
      Stamp HEAD as 10devel. · ca9112a4
      Tom Lane authored
      This is a good bit more complicated than the average new-version stamping
      commit, because it includes various adjustments in pursuit of changing
      from three-part to two-part version numbers.  It's likely some further
      work will be needed around that change; but this is enough to get through
      the regression tests, at least in Unix builds.
      
      Peter Eisentraut and Tom Lane
      ca9112a4
  21. Aug 08, 2016
    • Noah Misch's avatar
      Promote pg_dumpall shell/connstr quoting functions to src/fe_utils. · 41f18f02
      Noah Misch authored
      Rename these newly-extern functions with terms more typical of their new
      neighbors.  No functional changes; a subsequent commit will use them in
      more places.  Back-patch to 9.1 (all supported versions).  Back branches
      lack src/fe_utils, so instead rename the functions in place; the
      subsequent commit will copy them into the other programs using them.
      
      Security: CVE-2016-5424
      41f18f02
  22. Jun 10, 2016
  23. Apr 29, 2016
    • Andrew Dunstan's avatar
      Fix typo in VS2015 patch · 7dc54923
      Andrew Dunstan authored
      reported by Christian Ullrich
      7dc54923
    • Andrew Dunstan's avatar
      Support building with Visual Studio 2015 · 0fb54de9
      Andrew Dunstan authored
      Adjust the way we detect the locale. As a result the minumum Windows
      version supported by VS2015 and later is Windows Vista. Add some tweaks
      to remove new compiler warnings. Remove documentation references to the
      now obsolete msysGit.
      
      Michael Paquier, somewhat edited by me, reviewed by Christian Ullrich.
      
      Backpatch to 9.5
      0fb54de9
  24. Apr 22, 2016
  25. Apr 07, 2016
    • Noah Misch's avatar
      Standardize GetTokenInformation() error reporting. · f2b1b307
      Noah Misch authored
      Commit c22650cd sparked a discussion
      about diverse interpretations of "token user" in error messages.  Expel
      old and new specimens of that phrase by making all GetTokenInformation()
      callers report errors the way GetTokenUser() has been reporting them.
      These error conditions almost can't happen, so users are unlikely to
      observe this change.
      
      Reviewed by Tom Lane and Stephen Frost.
      f2b1b307
  26. Mar 29, 2016
    • Tom Lane's avatar
      Avoid possibly-unsafe use of Windows' FormatMessage() function. · 7abc1571
      Tom Lane authored
      Whenever this function is used with the FORMAT_MESSAGE_FROM_SYSTEM flag,
      it's good practice to include FORMAT_MESSAGE_IGNORE_INSERTS as well.
      Otherwise, if the message contains any %n insertion markers, the function
      will try to fetch argument strings to substitute --- which we are not
      passing, possibly leading to a crash.  This is exactly analogous to the
      rule about not giving printf() a format string you're not in control of.
      
      Noted and patched by Christian Ullrich.
      Back-patch to all supported branches.
      7abc1571
  27. Mar 09, 2016
  28. Feb 17, 2016
    • Joe Conway's avatar
      Add new system view, pg_config · a5c43b88
      Joe Conway authored
      Move and refactor the underlying code for the pg_config client
      application to src/common in support of sharing it with a new
      system information SRF called pg_config() which makes the same
      information available via SQL. Additionally wrap the SRF with a
      new system view, as called pg_config.
      
      Patch by me with extensive input and review by Michael Paquier
      and additional review by Alvaro Herrera.
      a5c43b88
  29. Jan 08, 2016
  30. Jan 07, 2016
    • Alvaro Herrera's avatar
      Windows: Make pg_ctl reliably detect service status · a9676139
      Alvaro Herrera authored
      pg_ctl is using isatty() to verify whether the process is running in a
      terminal, and if not it sends its output to Windows' Event Log ... which
      does the wrong thing when the output has been redirected to a pipe, as
      reported in bug #13592.
      
      To fix, make pg_ctl use the code we already have to detect service-ness:
      in the master branch, move src/backend/port/win32/security.c to src/port
      (with suitable tweaks so that it runs properly in backend and frontend
      environments); pg_ctl already has access to pgport so it Just Works.  In
      older branches, that's likely to cause trouble, so instead duplicate the
      required code in pg_ctl.c.
      
      Author: Michael Paquier
      Bug report and diagnosis: Egon Kocjan
      Backpatch: all supported branches
      a9676139
  31. Jan 02, 2016
  32. Nov 22, 2015
    • Tom Lane's avatar
      Adopt the GNU convention for handling tar-archive members exceeding 8GB. · 00cdd835
      Tom Lane authored
      The POSIX standard for tar headers requires archive member sizes to be
      printed in octal with at most 11 digits, limiting the representable file
      size to 8GB.  However, GNU tar and apparently most other modern tars
      support a convention in which oversized values can be stored in base-256,
      allowing any practical file to be a tar member.  Adopt this convention
      to remove two limitations:
      * pg_dump with -Ft output format failed if the contents of any one table
      exceeded 8GB.
      * pg_basebackup failed if the data directory contained any file exceeding
      8GB.  (This would be a fatal problem for installations configured with a
      table segment size of 8GB or more, and it has also been seen to fail when
      large core dump files exist in the data directory.)
      
      File sizes under 8GB are still printed in octal, so that no compatibility
      issues are created except in cases that would have failed entirely before.
      
      In addition, this patch fixes several bugs in the same area:
      
      * In 9.3 and later, we'd defined tarCreateHeader's file-size argument as
      size_t, which meant that on 32-bit machines it would write a corrupt tar
      header for file sizes between 4GB and 8GB, even though no error was raised.
      This broke both "pg_dump -Ft" and pg_basebackup for such cases.
      
      * pg_restore from a tar archive would fail on tables of size between 4GB
      and 8GB, on machines where either "size_t" or "unsigned long" is 32 bits.
      This happened even with an archive file not affected by the previous bug.
      
      * pg_basebackup would fail if there were files of size between 4GB and 8GB,
      even on 64-bit machines.
      
      * In 9.3 and later, "pg_basebackup -Ft" failed entirely, for any file size,
      on 64-bit big-endian machines.
      
      In view of these potential data-loss bugs, back-patch to all supported
      branches, even though removal of the documented 8GB limit might otherwise
      be considered a new feature rather than a bug fix.
      00cdd835
  33. Nov 17, 2015
  34. Aug 31, 2015
    • Tom Lane's avatar
      Remove support for Unix systems without the POSIX signal APIs. · a65e0864
      Tom Lane authored
      Remove configure's checks for HAVE_POSIX_SIGNALS, HAVE_SIGPROCMASK, and
      HAVE_SIGSETJMP.  These APIs are required by the Single Unix Spec v2
      (POSIX 1997), which we generally consider to define our minimum required
      set of Unix APIs.  Moreover, no buildfarm member has reported not having
      them since 2012 or before, which means that even if the code is still live
      somewhere, it's untested --- and we've made plenty of signal-handling
      changes of late.  So just take these APIs as given and save the cycles for
      configure probes for them.
      
      However, we can't remove as much C code as I'd hoped, because the Windows
      port evidently still uses the non-POSIX code paths for signal masking.
      Since we're largely emulating these BSD-style APIs for Windows anyway, it
      might be a good thing to switch over to POSIX-like notation and thereby
      remove a few more #ifdefs.  But I'm not in a position to code or test that.
      In the meantime, we can at least make things a bit more transparent by
      testing for WIN32 explicitly in these places.
      a65e0864
  35. Jul 25, 2015
    • Tom Lane's avatar
      Redesign tablesample method API, and do extensive code review. · dd7a8f66
      Tom Lane authored
      The original implementation of TABLESAMPLE modeled the tablesample method
      API on index access methods, which wasn't a good choice because, without
      specialized DDL commands, there's no way to build an extension that can
      implement a TSM.  (Raw inserts into system catalogs are not an acceptable
      thing to do, because we can't undo them during DROP EXTENSION, nor will
      pg_upgrade behave sanely.)  Instead adopt an API more like procedural
      language handlers or foreign data wrappers, wherein the only SQL-level
      support object needed is a single handler function identified by having
      a special return type.  This lets us get rid of the supporting catalog
      altogether, so that no custom DDL support is needed for the feature.
      
      Adjust the API so that it can support non-constant tablesample arguments
      (the original coding assumed we could evaluate the argument expressions at
      ExecInitSampleScan time, which is undesirable even if it weren't outright
      unsafe), and discourage sampling methods from looking at invisible tuples.
      Make sure that the BERNOULLI and SYSTEM methods are genuinely repeatable
      within and across queries, as required by the SQL standard, and deal more
      honestly with methods that can't support that requirement.
      
      Make a full code-review pass over the tablesample additions, and fix
      assorted bugs, omissions, infelicities, and cosmetic issues (such as
      failure to put the added code stanzas in a consistent ordering).
      Improve EXPLAIN's output of tablesample plans, too.
      
      Back-patch to 9.5 so that we don't have to support the original API
      in production.
      dd7a8f66
  36. Jul 17, 2015
    • Tom Lane's avatar
      Fix a low-probability crash in our qsort implementation. · 9d6077ab
      Tom Lane authored
      It's standard for quicksort implementations, after having partitioned the
      input into two subgroups, to recurse to process the smaller partition and
      then handle the larger partition by iterating.  This method guarantees
      that no more than log2(N) levels of recursion can be needed.  However,
      Bentley and McIlroy argued that checking to see which partition is smaller
      isn't worth the cycles, and so their code doesn't do that but just always
      recurses on the left partition.  In most cases that's fine; but with
      worst-case input we might need O(N) levels of recursion, and that means
      that qsort could be driven to stack overflow.  Such an overflow seems to
      be the only explanation for today's report from Yiqing Jin of a SIGSEGV
      in med3_tuple while creating an index of a couple billion entries with a
      very large maintenance_work_mem setting.  Therefore, let's spend the few
      additional cycles and lines of code needed to choose the smaller partition
      for recursion.
      
      Also, fix up the qsort code so that it properly uses size_t not int for
      some intermediate values representing numbers of items.  This would only
      be a live risk when sorting more than INT_MAX bytes (in qsort/qsort_arg)
      or tuples (in qsort_tuple), which I believe would never happen with any
      caller in the current core code --- but perhaps it could happen with
      call sites in third-party modules?  In any case, this is trouble waiting
      to happen, and the corrected code is probably if anything shorter and
      faster than before, since it removes sign-extension steps that had to
      happen when converting between int and size_t.
      
      In passing, move a couple of CHECK_FOR_INTERRUPTS() calls so that it's
      not necessary to preserve the value of "r" across them, and prettify
      the output of gen_qsort_tuple.pl a little.
      
      Back-patch to all supported branches.  The odds of hitting this issue
      are probably higher in 9.4 and up than before, due to the new ability
      to allocate sort workspaces exceeding 1GB, but there's no good reason
      to believe that it's impossible to crash older branches this way.
      9d6077ab
Loading