1. 19 Jul, 2021 1 commit
  2. 18 Jul, 2021 1 commit
    • Alexander Korotkov's avatar
      Support for unnest(multirange) · 244ad541
      Alexander Korotkov authored
      It has been spotted that multiranges lack of ability to decompose them into
      individual ranges.  Subscription and proper expanded object representation
      require substantial work, and it's too late for v14.  This commit
      provides the implementation of unnest(multirange), which is quite trivial.
      unnest(multirange) is defined as a polymorphic procedure.
      
      Catversion is bumped.
      
      Reported-by: Jonathan S. Katz
      Discussion: https://postgr.es/m/flat/60258efe-bd7e-4886-82e1-196e0cac5433%40postgresql.org
      Author: Alexander Korotkov
      Reviewed-by: Justin Pryzby, Jonathan S. Katz, Zhihong Yu, Tom Lane
      Reviewed-by: Alvaro Herrera
      244ad541
  3. 17 Jul, 2021 2 commits
  4. 16 Jul, 2021 4 commits
  5. 15 Jul, 2021 4 commits
  6. 14 Jul, 2021 4 commits
  7. 13 Jul, 2021 3 commits
    • Tom Lane's avatar
      Rename debug_invalidate_system_caches_always to debug_discard_caches. · 6201fa3c
      Tom Lane authored
      The name introduced by commit 4656e3d6 was agreed to be unreasonably
      long.  To match this change, rename initdb's recently-added
      --clobber-cache option to --discard-caches.
      
      Discussion: https://postgr.es/m/1374320.1625430433@sss.pgh.pa.us
      6201fa3c
    • David Rowley's avatar
      Robustify tuplesort's free_sort_tuple function · a92709fe
      David Rowley authored
      41469253e went to the trouble of removing a theoretical bug from
      free_sort_tuple by checking if the tuple was NULL before freeing it. Let's
      make this a little more robust by also setting the tuple to NULL so that
      should we be called again we won't end up doing a pfree on the already
      pfree'd tuple. Per advice from Tom Lane.
      
      Discussion: https://postgr.es/m/3188192.1626136953@sss.pgh.pa.us
      Backpatch-through: 9.6, same as 41469253e
      a92709fe
    • David Rowley's avatar
      Fix theoretical bug in tuplesort · a3b8d91c
      David Rowley authored
      This fixes a theoretical bug in tuplesort.c which, if a bounded sort was
      used in combination with a byval Datum sort (tuplesort_begin_datum), when
      switching the sort to a bounded heap in make_bounded_heap(), we'd call
      free_sort_tuple().  The problem was that when sorting Datums of a byval
      type, the tuple is NULL and free_sort_tuple() would free the memory for it
      regardless of that.  This would result in a crash.
      
      Here we fix that simply by adding a check to see if the tuple is NULL
      before trying to disassociate and free any memory belonging to it.
      
      The reason this bug is only theoretical is that nowhere in the current
      code base do we do tuplesort_set_bound() when performing a Datum sort.
      However, let's backpatch a fix for this as if any extension uses the code
      in this way then it's likely to cause problems.
      
      Author: Ronan Dunklau
      Discussion: https://postgr.es/m/CAApHDvpdoqNC5FjDb3KUTSMs5dg6f+XxH4Bg_dVcLi8UYAG3EQ@mail.gmail.com
      Backpatch-through: 9.6, oldest supported version
      a3b8d91c
  8. 12 Jul, 2021 6 commits
    • Tom Lane's avatar
      Probe for preadv/pwritev in a more macOS-friendly way. · e75da4f1
      Tom Lane authored
      Apple's mechanism for dealing with functions that are available
      in only some OS versions confuses AC_CHECK_FUNCS, and therefore
      AC_REPLACE_FUNCS.  We can use AC_CHECK_DECLS instead, so long as
      we enable -Werror=unguarded-availability-new.  This allows people
      compiling for macOS to control whether or not preadv/pwritev are
      used by setting MACOSX_DEPLOYMENT_TARGET, rather than supplying
      a back-rev SDK.  (Of course, the latter still works, too.)
      
      James Hilliard
      
      Discussion: https://postgr.es/m/20210122193230.25295-1-james.hilliard1@gmail.com
      e75da4f1
    • Peter Eisentraut's avatar
      doc: Fix typo in function prototype · 9b450b1f
      Peter Eisentraut authored
      9b450b1f
    • Heikki Linnakangas's avatar
      Remove dead assignment to local variable. · 23328080
      Heikki Linnakangas authored
      This should have been removed in commit 7e30c186, which split the loop
      into two. Only the first loop uses the 'from' variable; updating it in
      the second loop is bogus. It was never read after the first loop, so this
      was harmless and surely optimized away by the compiler, but let's be tidy.
      
      Backpatch to all supported versions.
      
      Author: Ranier Vilela
      Discussion: https://www.postgresql.org/message-id/CAEudQAoWq%2BAL3BnELHu7gms2GN07k-np6yLbukGaxJ1vY-zeiQ%40mail.gmail.com
      23328080
    • Peter Eisentraut's avatar
      doc: Make release note entries more accurate · 166fcf4a
      Peter Eisentraut authored
      Two tsquery-related release note entries had inaccuracies in the
      before and after examples.  Clean that up.
      166fcf4a
    • Michael Paquier's avatar
      Revert "Fix issues with Windows' stat() for files pending on deletion" · 5e60237a
      Michael Paquier authored
      This reverts commit 54fb8c7, as per the issues reported by fairywren
      when it comes to MinGW because of the lack of microsoft_native_stat()
      there.  Using just stat() for MSVC is not sufficient to take care of the
      concurrency problems with files pending on deletion.  It may be possible
      to paint some __MINGW64__ in the code to switch to a different
      implementation of stat() in this build context, but I am not sure either
      if relying on the implementation of stat() in MinGW to take care of the
      problems we are trying to fix is enough or not.  So this needs more
      study.
      
      Discussion: https://postgr.es/m/YOvOlfRrIO0yGtgw@paquier.xyz
      Backpatch-through: 14
      5e60237a
    • Michael Paquier's avatar
      Fix issues with Windows' stat() for files pending on deletion · de1510e2
      Michael Paquier authored
      The code introduced by bed90759 to enhance the stat() implementation on
      Windows for file sizes larger than 4GB fails to properly detect files
      pending for deletion with its method based on NtQueryInformationFile()
      or GetFileInformationByHandleEx(), as proved by Alexander Lakhin in a
      custom TAP test of his own.
      
      The method used in the implementation of open() to sleep and loop when
      when failing on ERROR_ACCESS_DENIED (EACCES) is showing much more
      stability, so switch to this method.  This could still lead to issues if
      the permission problem stays around for much longer than the timeout of
      1 second used, but that should (hopefully) never happen in
      performance-critical paths.  Still, there could be a point in increasing
      the timeouts for the sake of machines that handle heavy loads.
      
      Note that WIN32's open() now uses microsoft_native_stat() as it should
      be similar to stat() when working around issues with concurrent file
      deletions.
      
      I have spent some time testing this patch with pgbench in combination
      of the SQL functions from genfile.c, as well as running the TAP test
      provided on the thread with MSVC builds, and this looks much more
      stable than the previous method.
      
      Author: Alexander Lakhin
      Reviewed-by: Tom Lane, Michael Paquier,	Justin Pryzby
      Discussion: https://postgr.es/m/c3427edf-d7c0-ff57-90f6-b5de3bb62709@gmail.com
      Backpatch-through: 14
      de1510e2
  9. 11 Jul, 2021 2 commits
  10. 10 Jul, 2021 3 commits
  11. 09 Jul, 2021 8 commits
    • Tom Lane's avatar
      Un-break AIX build, take 2. · 9ffad7ae
      Tom Lane authored
      I incorrectly diagnosed the reason why hoverfly is unhappy.
      Looking closer, it appears that it fails to link libldap
      unless libssl is also present; so the problem was my
      idea of clearing LIBS before making the check.  Revert
      to essentially the original coding, except that instead
      of failing when libldap_r isn't there, use libldap.
      
      Per buildfarm member hoverfly.
      
      Discussion: https://postgr.es/m/17083-a19190d9591946a7@postgresql.org
      9ffad7ae
    • Alvaro Herrera's avatar
      libpq: Fix sending queries in pipeline aborted state · 1beaa654
      Alvaro Herrera authored
      When sending queries in pipeline mode, we were careless about leaving
      the connection in the right state so that PQgetResult would behave
      correctly; trying to read further results after sending a query after
      having read a result with an error would sometimes hang.  Fix by
      ensuring internal libpq state is changed properly.  All the state
      changes were being done by the callers of pqAppendCmdQueueEntry(); it
      would have become too repetitious to have this logic in each of them, so
      instead put it all in that function and relieve callers of the
      responsibility.
      
      Add a test to verify this case.  Without the code fix, this new test
      hangs sometimes.
      
      Also, document that PQisBusy() would return false when no queries are
      pending result.  This is not intuitively obvious, and NULL would be
      obtained by calling PQgetResult() at that point, which is confusing.
      Wording by Boris Kolpackov.
      
      In passing, fix bogus use of "false" to mean "0", per Ranier Vilela.
      
      Backpatch to 14.
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Reported-by: default avatarBoris Kolpackov <boris@codesynthesis.com>
      Discussion: https://postgr.es/m/boris.20210624103805@codesynthesis.com
      1beaa654
    • Tom Lane's avatar
      Un-break AIX build. · 7f2eca6f
      Tom Lane authored
      In commit d0a02bdb8, I'd supposed that uniformly probing for
      ldap_bind would make the intent clearer.  However, that seems
      not to work on AIX, for obscure reasons (maybe it's a macro
      there?).  Revert to the former behavior of probing
      ldap_simple_bind for thread-safe cases and ldap_bind otherwise.
      
      Per buildfarm member hoverfly.
      
      Discussion: https://postgr.es/m/17083-a19190d9591946a7@postgresql.org
      7f2eca6f
    • Tom Lane's avatar
      Avoid creating a RESULT RTE that's marked LATERAL. · 1d98fdae
      Tom Lane authored
      Commit 7266d099 added code to pull up simple constant function
      results, converting the RTE_FUNCTION RTE to a dummy RTE_RESULT
      RTE since it no longer need be scanned.  But I forgot to clear
      the LATERAL flag if the RTE has it set.  If the function reduced
      to a constant, it surely contains no lateral references so this
      simplification is logically OK.  It's needed because various other
      places will Assert that RESULT RTEs aren't LATERAL.
      
      Per bug #17097 from Yaoguang Chen.  Back-patch to v13 where the
      faulty code came in.
      
      Discussion: https://postgr.es/m/17097-3372ef9f798fc94f@postgresql.org
      1d98fdae
    • Tom Lane's avatar
      Update configure's probe for libldap to work with OpenLDAP 2.5. · 5620ec83
      Tom Lane authored
      The separate libldap_r is gone and libldap itself is now always
      thread-safe.  Unfortunately there seems no easy way to tell by
      inspection whether libldap is thread-safe, so we have to take
      it on faith that libldap is thread-safe if there's no libldap_r.
      That should be okay, as it appears that libldap_r was a standard
      part of the installation going back at least 20 years.
      
      Report and patch by Adrian Ho.  Back-patch to all supported
      branches, since people might try to build any of them with
      a newer OpenLDAP.
      
      Discussion: https://postgr.es/m/17083-a19190d9591946a7@postgresql.org
      5620ec83
    • Tom Lane's avatar
      Reject cases where a query in WITH rewrites to just NOTIFY. · 39b6e85f
      Tom Lane authored
      Since the executor can't cope with a utility statement appearing
      as a node of a plan tree, we can't support cases where a rewrite
      rule inserts a NOTIFY into an INSERT/UPDATE/DELETE command appearing
      in a WITH clause of a larger query.  (One can imagine ways around
      that, but it'd be a new feature not a bug fix, and so far there's
      been no demand for it.)  RewriteQuery checked for this, but it
      missed the case where the DML command rewrites to *only* a NOTIFY.
      That'd lead to crashes later on in planning.  Add the missed check,
      and improve the level of testing of this area.
      
      Per bug #17094 from Yaoguang Chen.  It's been busted since WITH
      was introduced, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/17094-bf15dff55eaf2e28@postgresql.org
      39b6e85f
    • Thomas Munro's avatar
      Remove more obsolete comments about semaphores. · 8d48a343
      Thomas Munro authored
      Commit 6753333f stopped using semaphores as the sleep/wake mechanism for
      heavyweight locks, but some obsolete references to that scheme remained
      in comments.  As with similar commit 25b93a29, back-patch all the way.
      Reviewed-by: default avatarDaniel Gustafsson <daniel@yesql.se>
      Discussion: https://postgr.es/m/CA%2BhUKGLafjB1uzXcy%3D%3D2L3cy7rjHkqOVn7qRYGBjk%3D%3DtMJE7Yg%40mail.gmail.com
      8d48a343
    • David Rowley's avatar
      Fix incorrect return value in pg_size_pretty(bigint) · 6de3a21b
      David Rowley authored
      Due to how pg_size_pretty(bigint) was implemented, it's possible that when
      given a negative number of bytes that the returning value would not match
      the equivalent positive return value when given the equivalent positive
      number of bytes.  This was due to two separate issues.
      
      1. The function used bit shifting to convert the number of bytes into
      larger units.  The rounding performed by bit shifting is not the same as
      dividing.  For example -3 >> 1 = -2, but -3 / 2 = -1.  These two
      operations are only equivalent with positive numbers.
      
      2. The half_rounded() macro rounded towards positive infinity.  This meant
      that negative numbers rounded towards zero and positive numbers rounded
      away from zero.
      
      Here we fix #1 by dividing the values instead of bit shifting.  We fix #2
      by adjusting the half_rounded macro always to round away from zero.
      
      Additionally, adjust the pg_size_pretty(numeric) function to be more
      explicit that it's using division rather than bit shifting.  A casual
      observer might have believed bit shifting was used due to a static
      function being named numeric_shift_right.  However, that function was
      calculating the divisor from the number of bits and performed division.
      Here we make that more clear.  This change is just cosmetic and does not
      affect the return value of the numeric version of the function.
      
      Here we also add a set of regression tests both versions of
      pg_size_pretty() which test the values directly before and after the
      function switches to the next unit.
      
      This bug was introduced in 8a1fab36. Prior to that negative values were
      always displayed in bytes.
      
      Author: Dean Rasheed, David Rowley
      Discussion: https://postgr.es/m/CAEZATCXnNW4HsmZnxhfezR5FuiGgp+mkY4AzcL5eRGO4fuadWg@mail.gmail.com
      Backpatch-through: 9.6, where the bug was introduced.
      6de3a21b
  12. 08 Jul, 2021 2 commits