1. 26 Aug, 2020 2 commits
  2. 25 Aug, 2020 3 commits
  3. 24 Aug, 2020 2 commits
  4. 22 Aug, 2020 4 commits
  5. 21 Aug, 2020 5 commits
    • Bruce Momjian's avatar
      docs: add COMMENT examples for new features, rename rtree · bfd78c0b
      Bruce Momjian authored
      Reported-by: Jürgen Purtz
      
      Discussion: https://postgr.es/m/15ec5428-d46a-1725-f38d-44986a977abb@purtz.de
      
      Author: Jürgen Purtz
      
      Backpatch-through: 11
      bfd78c0b
    • Tom Lane's avatar
      Fix handling of CREATE TABLE LIKE with inheritance. · 50289819
      Tom Lane authored
      If a CREATE TABLE command uses both LIKE and traditional inheritance,
      Vars in CHECK constraints and expression indexes that are absorbed
      from a LIKE parent table tended to get mis-numbered, resulting in
      wrong answers and/or bizarre error messages (though probably not any
      actual crashes, thanks to validation occurring in the executor).
      
      In v12 and up, the same could happen to Vars in GENERATED expressions,
      even in cases with no LIKE clause but multiple traditional-inheritance
      parents.
      
      The cause of the problem for LIKE is that parse_utilcmd.c supposed
      it could renumber such Vars correctly during transformCreateStmt(),
      which it cannot since we have not yet accounted for columns added via
      inheritance.  Fix that by postponing processing of LIKE INCLUDING
      CONSTRAINTS, DEFAULTS, GENERATED, INDEXES till after we've performed
      DefineRelation().
      
      The error with GENERATED and multiple inheritance is a simple oversight
      in MergeAttributes(); it knows it has to renumber Vars in inherited
      CHECK constraints, but forgot to apply the same processing to inherited
      GENERATED expressions (a/k/a defaults).
      
      Per bug #16272 from Tom Gottfried.  The non-GENERATED variants of the
      issue are ancient, presumably dating right back to the addition of
      CREATE TABLE LIKE; hence back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/16272-6e32da020e9a9381@postgresql.org
      50289819
    • Fujii Masao's avatar
      Fix explain regression test failure. · eabba4a3
      Fujii Masao authored
      Commit 9d701e62 caused the regression test for EXPLAIN to fail on
      the buildfarm member prion. This happened because of instability of
      test output, i.e., in text format, whether "Planning:" line is output
      varies depending on the system state.
      
      This commit updated the regression test so that it ignores that
      "Planning:" line to produce more stable test output and get rid of
      the test failure.
      
      Back-patch to v13.
      
      Author: Fujii Masao
      Discussion: https://postgr.es/m/1803897.1598021621@sss.pgh.pa.us
      eabba4a3
    • Fujii Masao's avatar
      Rework EXPLAIN for planner's buffer usage. · 9d701e62
      Fujii Masao authored
      Commit ce77abe6 allowed EXPLAIN (BUFFERS) to report the information
      on buffer usage during planning phase. However three issues were
      reported regarding this feature.
      
      (1) Previously, EXPLAIN option BUFFERS required ANALYZE. So the query
          had to be actually executed by specifying ANALYZE even when we
          want to see only the planner's buffer usage. This was inconvenient
          especially when the query was write one like DELETE.
      
      (2) EXPLAIN included the planner's buffer usage in summary
          information. So SUMMARY option had to be enabled to report that.
          Also this format was confusing.
      
      (3) The output structure for planning information was not consistent
          between TEXT format and the others. For example, "Planning" tag
          was output in JSON format, but not in TEXT format.
      
      For (1), this commit allows us to perform EXPLAIN (BUFFERS) without
      ANALYZE to report the planner's buffer usage.
      
      For (2), this commit changed EXPLAIN output so that the planner's
      buffer usage is reported before summary information.
      
      For (3), this commit made the output structure for planning
      information more consistent between the formats.
      
      Back-patch to v13 where the planner's buffer usage was allowed to
      be reported in EXPLAIN.
      
      Reported-by: Pierre Giraud, David Rowley
      Author: Fujii Masao
      Reviewed-by: David Rowley, Julien Rouhaud, Pierre Giraud
      Discussion: https://postgr.es/m/07b226e6-fa49-687f-b110-b7c37572f69e@dalibo.com
      9d701e62
    • Fujii Masao's avatar
      Fix typos in comments. · d259afa7
      Fujii Masao authored
      Author: Masahiko Sawada
      Reviewed-by: Fujii Masao
      Discussion: https://postgr.es/m/CA+fd4k4m9hFSrRLB3etPWO5_v5=MujVZWRtz63q+55hM0Dz25Q@mail.gmail.com
      d259afa7
  6. 20 Aug, 2020 4 commits
  7. 19 Aug, 2020 2 commits
    • Tom Lane's avatar
      Suppress unnecessary RelabelType nodes in yet more cases. · 20729324
      Tom Lane authored
      Commit a477bfc1 fixed eval_const_expressions() to ensure that it
      didn't generate unnecessary RelabelType nodes, but I failed to notice
      that some other places in the planner had the same issue.  Really
      noplace in the planner should be using plain makeRelabelType(), for
      fear of generating expressions that should be equal() to semantically
      equivalent trees, but aren't.
      
      An example is that because canonicalize_ec_expression() failed
      to be careful about this, we could end up with an equivalence class
      containing both a plain Const, and a Const-with-RelabelType
      representing exactly the same value.  So far as I can tell this led to
      no visible misbehavior, but we did waste a bunch of cycles generating
      and evaluating "Const = Const-with-RelabelType" to prove such entries
      are redundant.
      
      Hence, move the support function added by a477bfc1 to where it can
      be more generally useful, and use it in the places where planner code
      previously used makeRelabelType.
      
      Back-patch to v12, like the previous patch.  While I have no concrete
      evidence of any real misbehavior here, it's certainly possible that
      I overlooked a case where equivalent expressions that aren't equal()
      could cause a user-visible problem.  In any case carrying extra
      RelabelType nodes through planning to execution isn't very desirable.
      
      Discussion: https://postgr.es/m/1311836.1597781384@sss.pgh.pa.us
      20729324
    • Fujii Masao's avatar
      Add pg_backend_memory_contexts system view. · 3e98c0ba
      Fujii Masao authored
      This view displays the usages of all the memory contexts of the server
      process attached to the current session. This information is useful to
      investigate the cause of backend-local memory bloat.
      
      This information can be also collected by calling
      MemoryContextStats(TopMemoryContext) via a debugger. But this technique
      cannot be uesd in some environments because no debugger is available there.
      And it outputs lots of text messages and it's not easy to analyze them.
      So, pg_backend_memory_contexts view allows us to access to backend-local
      memory contexts information more easily.
      
      Bump catalog version.
      
      Author: Atsushi Torikoshi, Fujii Masao
      Reviewed-by: Tatsuhito Kasahara, Andres Freund, Daniel Gustafsson, Robert Haas, Michael Paquier
      Discussion: https://postgr.es/m/72a656e0f71d0860161e0b3f67e4d771@oss.nttdata.com
      3e98c0ba
  8. 18 Aug, 2020 5 commits
    • Andres Freund's avatar
      Fix race condition in snapshot caching when 2PC is used. · 07f32fcd
      Andres Freund authored
      When preparing a transaction xactCompletionCount needs to be
      incremented, even though the transaction has not committed
      yet. Otherwise the snapshot used within the transaction otherwise can
      get reused outside of the prepared transaction. As GetSnapshotData()
      does not include the current xid when building a snapshot, reuse would
      not be correct.
      
      Somewhat surprisingly the regression tests only rarely show incorrect
      results without the fix. The reason for that is that often the
      snapshot's xmax will be >= the backend xid, yielding a snapshot that
      is correct, despite the bug.
      
      I'm working on a reliable test for the bug, but it seems worth seeing
      whether this fixes all the BF failures while I do.
      
      Author: Andres Freund <andres@anarazel.de>
      Discussion: https://postgr.es/m/E1k7tGP-0005V0-5k@gemulon.postgresql.org
      07f32fcd
    • Heikki Linnakangas's avatar
      Avoid non-constant format string argument to fprintf(). · 73447820
      Heikki Linnakangas authored
      As Tom Lane pointed out, it could defeat the compiler's printf() format
      string verification.
      
      Backpatch to v12, like that patch that introduced it.
      
      Discussion: https://www.postgresql.org/message-id/1069283.1597672779%40sss.pgh.pa.us
      73447820
    • Andres Freund's avatar
      snapshot scalability: cache snapshots using a xact completion counter. · 623a9ba7
      Andres Freund authored
      Previous commits made it faster/more scalable to compute snapshots. But not
      building a snapshot is still faster. Now that GetSnapshotData() does not
      maintain RecentGlobal* anymore, that is actually not too hard:
      
      This commit introduces xactCompletionCount, which tracks the number of
      top-level transactions with xids (i.e. which may have modified the database)
      that completed in some form since the start of the server.
      
      We can avoid rebuilding the snapshot's contents whenever the current
      xactCompletionCount is the same as it was when the snapshot was
      originally built.  Currently this check happens while holding
      ProcArrayLock. While it's likely possible to perform the check without
      acquiring ProcArrayLock, it seems better to do that separately /
      later, some careful analysis is required. Even with the lock this is a
      significant win on its own.
      
      On a smaller two socket machine this gains another ~1.03x, on a larger
      machine the effect is roughly double (earlier patch version tested
      though).  If we were able to safely avoid the lock there'd be another
      significant gain on top of that.
      
      Author: Andres Freund <andres@anarazel.de>
      Reviewed-By: default avatarRobert Haas <robertmhaas@gmail.com>
      Reviewed-By: default avatarThomas Munro <thomas.munro@gmail.com>
      Reviewed-By: default avatarDavid Rowley <dgrowleyml@gmail.com>
      Discussion: https://postgr.es/m/20200301083601.ews6hz5dduc3w2se@alap3.anarazel.de
      623a9ba7
    • Michael Paquier's avatar
      Fix use-after-release issue in PL/Sample · 51300b45
      Michael Paquier authored
      Introduced in adbe62d0.  Per buildfarm member prion, when using
      RELCACHE_FORCE_RELEASE.
      51300b45
    • Michael Paquier's avatar
      Add PL/Sample to src/test/modules/ · adbe62d0
      Michael Paquier authored
      PL/Sample is an example template of procedural-language handler.  This
      can be used as a base to implement a custom PL, or as a facility to test
      APIs dedicated to PLs.  Much more could be done in this module, like
      adding a simple validator, but this is left as future work.
      
      The documentation included originally some C code to understand the
      basics of PL handler implementation, but it was outdated, and not really
      helpful either if trying to implement a new procedural language,
      particularly when it came to the integration of a PL installation with
      CREATE EXTENSION.
      
      Author: Mark Wong
      Reviewed-by: Tom Lane, Michael Paquier
      Discussion: https://postgr.es/m/20200612172648.GA3327@2ndQuadrant.com
      adbe62d0
  9. 17 Aug, 2020 6 commits
  10. 16 Aug, 2020 3 commits
  11. 15 Aug, 2020 4 commits