1. 04 Jan, 2022 1 commit
    • Alvaro Herrera's avatar
      Allow special SKIP LOCKED condition in Assert() · f185f35a
      Alvaro Herrera authored
      Under concurrency, it is possible for two sessions to be merrily locking
      and releasing a tuple and marking it again as HEAP_XMAX_INVALID all the
      while a third session attempts to lock it, miserably fails at it, and
      then contemplates life, the universe and everything only to eventually
      fail an assertion that said bit is not set.  Before SKIP LOCKED that was
      indeed a reasonable expectation, but alas! commit df630b0d falsified
      it.
      
      This bug is as old as time itself, and even older, if you think time
      begins with the oldest supported branch.  Therefore, backpatch to all
      supported branches.
      
      Author: Simon Riggs <simon.riggs@enterprisedb.com>
      Discussion: https://postgr.es/m/CANbhV-FeEwMnN8yuMyss7if1ZKjOKfjcgqB26n8pqu1e=q0ebg@mail.gmail.com
      f185f35a
  2. 03 Jan, 2022 2 commits
    • Tom Lane's avatar
      Fix index-only scan plans, take 2. · d228af79
      Tom Lane authored
      Commit 4ace45677 failed to fix the problem fully, because the
      same issue of attempting to fetch a non-returnable index column
      can occur when rechecking the indexqual after using a lossy index
      operator.  Moreover, it broke EXPLAIN for such indexquals (which
      indicates a gap in our test cases :-().
      
      Revert the code changes of 4ace45677 in favor of adding a new field
      to struct IndexOnlyScan, containing a version of the indexqual that
      can be executed against the index-returned tuple without using any
      non-returnable columns.  (The restrictions imposed by check_index_only
      guarantee this is possible, although we may have to recompute indexed
      expressions.)  Support construction of that during setrefs.c
      processing by marking IndexOnlyScan.indextlist entries as resjunk
      if they can't be returned, rather than removing them entirely.
      (We could alternatively require setrefs.c to look up the IndexOptInfo
      again, but abusing resjunk this way seems like a reasonably safe way
      to avoid needing to do that.)
      
      This solution isn't great from an API-stability standpoint: if there
      are any extensions out there that build IndexOnlyScan structs directly,
      they'll be broken in the next minor releases.  However, only a very
      invasive extension would be likely to do such a thing.  There's no
      change in the Path representation, so typical planner extensions
      shouldn't have a problem.
      
      As before, back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/3179992.1641150853@sss.pgh.pa.us
      Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org
      d228af79
    • Michael Paquier's avatar
      pg_stat_statements: Remove obsolete comment · 52d50261
      Michael Paquier authored
      Since 4f0b0966, pgss_store() does nothing if compute_query_id is disabled
      or if no other module computed a query identifier, but the top comment
      of this function did not reflect that.  This behavior is already
      documented in its own code path, and this just removes the inconsistent
      comment.
      
      Author: Kyotaro Horiguchi
      Reviewed-by: Julien Rouhaud
      Discussion: https://postgr.es/m/20211122.153823.1325120762360533122.horikyota.ntt@gmail.com
      Backpatch-through: 14
      52d50261
  3. 02 Jan, 2022 1 commit
  4. 01 Jan, 2022 1 commit
    • Tom Lane's avatar
      Fix index-only scan plans when not all index columns can be returned. · cabea571
      Tom Lane authored
      If an index has both returnable and non-returnable columns, and one of
      the non-returnable columns is an expression using a Var that is in a
      returnable column, then a query returning that expression could result
      in an index-only scan plan that attempts to read the non-returnable
      column, instead of recomputing the expression from the returnable
      column as intended.
      
      To fix, redefine the "indextlist" list of an IndexOnlyScan plan node
      as containing null Consts in place of any non-returnable columns.
      This solves the problem by preventing setrefs.c from falsely matching
      to such entries.  The executor is happy since it only cares about the
      exposed types of the entries, and ruleutils.c doesn't care because a
      correct plan won't reference those entries.  I considered some other
      ways to prevent setrefs.c from doing the wrong thing, but this way
      seems good since (a) it allows a very localized fix, (b) it makes
      the indextlist structure more compact in many cases, and (c) the
      indextlist is now a more faithful representation of what the index AM
      will actually produce, viz. nulls for any non-returnable columns.
      
      This is easier to hit since we introduced included columns, but it's
      possible to construct failing examples without that, as per the
      added regression test.  Hence, back-patch to all supported branches.
      
      Per bug #17350 from Louis Jachiet.
      
      Discussion: https://postgr.es/m/17350-b5bdcf476e5badbb@postgresql.org
      cabea571
  5. 30 Dec, 2021 2 commits
  6. 22 Dec, 2021 3 commits
  7. 16 Dec, 2021 1 commit
    • Tom Lane's avatar
      Ensure casting to typmod -1 generates a RelabelType. · f9a8bc9f
      Tom Lane authored
      Fix the code changed by commit 5c056b0c2 so that we always generate
      RelabelType, not something else, for a cast to unspecified typmod.
      Otherwise planner optimizations might not happen.
      
      It appears we missed this point because the previous experiments were
      done on type numeric: the parser undesirably generates a call on the
      numeric() length-coercion function, but then numeric_support()
      optimizes that down to a RelabelType, so that everything seems fine.
      It misbehaves for types that have a non-optimized length coercion
      function, such as bpchar.
      
      Per report from John Naylor.  Back-patch to all supported branches,
      as the previous patch eventually was.  Unfortunately, that no longer
      includes 9.6 ... we really shouldn't put this type of change into a
      nearly-EOL branch.
      
      Discussion: https://postgr.es/m/CAFBsxsEfbFHEkouc+FSj+3K1sHipLPbEC67L0SAe-9-da8QtYg@mail.gmail.com
      f9a8bc9f
  8. 15 Dec, 2021 1 commit
    • Michael Paquier's avatar
      Adjust behavior of some env settings for the TAP tests of MSVC · 4ddbd745
      Michael Paquier authored
      edc2332 has introduced in vcregress.pl some control on the environment
      variables LZ4, TAR and GZIP_PROGRAM to allow any TAP tests to be able
      use those commands.  This makes the settings more consistent with
      src/Makefile.global.in, as the same default gets used for Make and MSVC
      builds.
      
      Each parameter can be changed in buildenv.pl, but as a default gets
      assigned after loading buldenv.pl, it is not possible to unset any of
      these, and using an empty value would not work with "||=" either.  As
      some environments may not have a compatible command in their PATH (tar
      coming from MinGW is an issue, for one), this could break tests without
      an exit path to bypass any failing test.  This commit changes things so
      as the default values for LZ4, TAR and GZIP_PROGRAM are assigned before
      loading buildenv.pl, not after.  This way, we keep the same amount of
      compatibility as a GNU build with the same defaults, and it becomes
      possible to unset any of those values.
      
      While on it, this adds some documentation about those three variables in
      the section dedicated to the TAP tests for MSVC.
      
      Per discussion with Andrew Dunstan.
      
      Discussion: https://postgr.es/m/YbGYe483803il3X7@paquier.xyz
      Backpatch-through: 10
      4ddbd745
  9. 14 Dec, 2021 2 commits
  10. 13 Dec, 2021 3 commits
  11. 09 Dec, 2021 2 commits
  12. 08 Dec, 2021 5 commits
  13. 07 Dec, 2021 2 commits
  14. 03 Dec, 2021 2 commits
  15. 02 Dec, 2021 2 commits
    • Tom Lane's avatar
      On Windows, close the client socket explicitly during backend shutdown. · 4cd29285
      Tom Lane authored
      It turns out that this is necessary to keep Winsock from dropping any
      not-yet-sent data, such as an error message explaining the reason for
      process termination.  It's pretty weird that the implicit close done
      by the kernel acts differently from an explicit close, but it's hard
      to argue with experimental results.
      
      Independently submitted by Alexander Lakhin and Lars Kanis (comments
      by me, though).  Back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/90b34057-4176-7bb0-0dbb-9822a5f6425b@greiz-reinsdorf.de
      Discussion: https://postgr.es/m/16678-253e48d34dc0c376@postgresql.org
      4cd29285
    • Michael Paquier's avatar
      Move into separate file all the SQL queries used in pg_upgrade tests · b6dac98b
      Michael Paquier authored
      The existing pg_upgrade/test.sh and the buildfarm code have been holding
      the same set of SQL queries when doing cross-version upgrade tests to
      adapt the objects created by the regression tests before the upgrade
      (mostly, incompatible or non-existing objects need to be dropped from
      the origin, perhaps re-created).
      
      This moves all those SQL queries into a new, separate, file with a set
      of \if clauses to handle the version checks depending on the old version
      of the cluster to-be-upgraded.
      
      The long-term plan is to make the buildfarm code re-use this new SQL
      file, so as committers are able to fix any compatibility issues in the
      tests of pg_upgrade with a refresh of the core code, without having to
      poke at the buildfarm client.  Note that this is only able to handle the
      main regression test suite, and that nothing is done yet for contrib
      modules yet (these have more issues like their database names).
      
      A backpatch down to 10 is done, adapting the version checks as this
      script needs to be only backward-compatible, so as it becomes possible
      to clean up a maximum amount of code within the buildfarm client.
      
      Author: Justin Pryzby, Michael Paquier
      Discussion: https://postgr.es/m/20201206180248.GI24052@telsasoft.com
      Backpatch-through: 10
      b6dac98b
  16. 01 Dec, 2021 2 commits
    • Tom Lane's avatar
      Avoid leaking memory during large-scale REASSIGN OWNED BY operations. · 8f4b0200
      Tom Lane authored
      The various ALTER OWNER routines tend to leak memory in
      CurrentMemoryContext.  That's not a problem when they're only called
      once per command; but in this usage where we might be touching many
      objects, it can amount to a serious memory leak.  Fix that by running
      each call in a short-lived context.
      
      (DROP OWNED BY likely has a similar issue, except that you'll probably
      run out of lock table space before noticing.  REASSIGN is worth fixing
      since for most non-table object types, it won't take any lock.)
      
      Back-patch to all supported branches.  Unfortunately, in the back
      branches this helps to only a limited extent, since the sinval message
      queue bloats quite a lot in this usage before commit 3aafc030a,
      consuming memory more or less comparable to what's actually leaked.
      Still, it's clearly a leak with a simple fix, so we might as well fix it.
      
      Justin Pryzby, per report from Guillaume Lelarge
      
      Discussion: https://postgr.es/m/CAECtzeW2DAoioEGBRjR=CzHP6TdL=yosGku8qZxfX9hhtrBB0Q@mail.gmail.com
      8f4b0200
    • Amit Kapila's avatar
      Doc: Add "Attach Partition" limitation during logical replication. · 4b8eec71
      Amit Kapila authored
      ATTACHing a table into a partition tree whose root is published using a
      publication with publish_via_partition_root set to true does not result in
      the table's existing contents being replicated. This happens because
      subscriber doesn't consider replicating the newly attached partition as
      the root table is already in a 'ready' state.
      
      This behavior was introduced in PG13 (83fd4532) where we allowed to
      publish partition changes via ancestors.
      
      We can consider fixing this limitation in the future.
      
      Author: Amit Langote
      Reviewed-by: Hou Zhijie, Amit Kapila
      Backpatch-through: 13
      Discussion: https://postgr.es/m/OS0PR01MB5716E97F00732B52DC2BBC2594989@OS0PR01MB5716.jpnprd01.prod.outlook.com
      4b8eec71
  17. 30 Nov, 2021 2 commits
    • Tom Lane's avatar
      Cope with cross-compiling when checking for a random-number source. · 175edafd
      Tom Lane authored
      Commit 16f96c74 neglected to consider the possibility of cross-compiling,
      causing cross-compiles to fail at the configure stage unless you'd
      selected --with-openssl.  Since we're now more or less assuming that
      /dev/urandom is available everywhere, it seems reasonable to assume
      that the cross-compile target has it too, rather than failing.
      
      Per complaint from Vincas Dargis.  Back-patch to v14 where this came in.
      
      Discussion: https://postgr.es/m/0dc14a31-acaf-8cae-0df4-a87339b22bd9@gmail.com
      175edafd
    • Michael Paquier's avatar
      Fix compatibility thinko for fstat() on standard streams in win32stat.c · 5550a9c3
      Michael Paquier authored
      GetFinalPathNameByHandleA() cannot be used in compilation environments
      where _WIN32_WINNT < 0x0600, meaning at least Windows XP used by some
      buildfarm members under MinGW that Postgres still needs to support.
      This was reported as a compilation warning by the buildfarm, but this is
      actually worse than the report as the code would have not worked.
      
      Instead, this switches to GetFileInformationByHandle() that is able to
      fail for standard streams and succeed for redirected ones, which is what
      we are looking for herein the code emulating fstat().  We also know that
      it is able to work in all the environments still supported, thanks to
      the existing logic of win32stat.c.
      
      Issue introduced by 10260c7, so backpatch down to 14.
      
      Reported-by: Justin Pryzby, via buildfarm member jacana
      Author: Michael Paquier
      Reviewed-by: Juan José Santamaría Flecha
      Discussion: https://postgr.es/m/20211129050122.GK17618@telsasoft.com
      Backpatch-through: 14
      5550a9c3
  18. 29 Nov, 2021 1 commit
  19. 26 Nov, 2021 4 commits
  20. 25 Nov, 2021 1 commit