1. 31 Aug, 2020 11 commits
  2. 30 Aug, 2020 3 commits
    • Tom Lane's avatar
      Mark factorial operator, and postfix operators in general, as deprecated. · 6ca547cf
      Tom Lane authored
      Per discussion, we're planning to remove parser support for postfix
      operators in order to simplify the grammar.  So it behooves us to
      put out a deprecation notice at least one release before that.
      
      There is only one built-in postfix operator, ! for factorial.
      Label it deprecated in the docs and in pg_description, and adjust
      some examples that formerly relied on it.  (The sister prefix
      operator !! is also deprecated.  We don't really have to remove
      that one, but since we're suggesting that people use factorial()
      instead, it seems better to remove both operators.)
      
      Also state in the CREATE OPERATOR ref page that postfix operators
      in general are going away.
      
      Although this changes the initial contents of pg_description,
      I did not force a catversion bump; it doesn't seem essential.
      
      In v13, also back-patch 4c5cf543, so that there's someplace for
      the <link>s to point to.
      
      Mark Dilger and John Naylor, with some adjustments by me
      
      Discussion: https://postgr.es/m/BE2DF53D-251A-4E26-972F-930E523580E9@enterprisedb.com
      6ca547cf
    • Tom Lane's avatar
      Redefine pg_class.reltuples to be -1 before the first VACUUM or ANALYZE. · 3d351d91
      Tom Lane authored
      Historically, we've considered the state with relpages and reltuples
      both zero as indicating that we do not know the table's tuple density.
      This is problematic because it's impossible to distinguish "never yet
      vacuumed" from "vacuumed and seen to be empty".  In particular, a user
      cannot use VACUUM or ANALYZE to override the planner's normal heuristic
      that an empty table should not be believed to be empty because it is
      probably about to get populated.  That heuristic is a good safety
      measure, so I don't care to abandon it, but there should be a way to
      override it if the table is indeed intended to stay empty.
      
      Hence, represent the initial state of ignorance by setting reltuples
      to -1 (relpages is still set to zero), and apply the minimum-ten-pages
      heuristic only when reltuples is still -1.  If the table is empty,
      VACUUM or ANALYZE (but not CREATE INDEX) will override that to
      reltuples = relpages = 0, and then we'll plan on that basis.
      
      This requires a bunch of fiddly little changes, but we can get rid of
      some ugly kluges that were formerly needed to maintain the old definition.
      
      One notable point is that FDWs' GetForeignRelSize methods will see
      baserel->tuples = -1 when no ANALYZE has been done on the foreign table.
      That seems like a net improvement, since those methods were formerly
      also in the dark about what baserel->tuples = 0 really meant.  Still,
      it is an API change.
      
      I bumped catversion because code predating this change would get confused
      by seeing reltuples = -1.
      
      Discussion: https://postgr.es/m/F02298E0-6EF4-49A1-BCB6-C484794D9ACC@thebuild.com
      3d351d91
    • Michael Paquier's avatar
      Reset indisreplident for an invalid index in DROP INDEX CONCURRENTLY · 9511fb37
      Michael Paquier authored
      A failure when dropping concurrently an index used in a replica identity
      could leave in pg_index an index marked as !indisvalid and
      indisreplident.  Reindexing this index would switch back indisvalid to
      true, and if the replica identity of the parent relation was switched to
      use a different index, it would be possible to finish with more than one
      index marked as indisreplident.  If that were to happen, this could mess
      up with the relation cache as an incorrect index could be used for the
      replica identity.
      
      Indexes marked as invalid are discarded as candidates for the replica
      identity, as of RelationGetIndexList(), so similarly to what is done
      with indisclustered, resetting indisreplident when the index is marked
      as invalid keeps things consistent.  REINDEX CONCURRENTLY's swapping
      already resets the flag for the old index, while the new index inherits
      the value of the old index to-be-dropped, so only DROP INDEX was an
      issue.
      
      Even if this is a bug, the sequence able to reproduce a problem requires
      a failure while running DROP INDEX CONCURRENTLY, something unlikely
      going to happen in the field, so no backpatch is done.
      
      Author: Michael Paquier
      Reviewed-by: Dmitry Dolgov
      Discussion: https://postgr.es/m/20200827025721.GN2017@paquier.xyz
      9511fb37
  3. 28 Aug, 2020 3 commits
  4. 27 Aug, 2020 2 commits
    • Tom Lane's avatar
      Fix code for re-finding scan position in a multicolumn GIN index. · 10564ee0
      Tom Lane authored
      collectMatchBitmap() needs to re-find the index tuple it was previously
      looking at, after transiently dropping lock on the index page it's on.
      The tuple should still exist and be at its prior position or somewhere
      to the right of that, since ginvacuum never removes tuples but
      concurrent insertions could add one.  However, there was a thinko in
      that logic, to the effect of expecting any inserted tuples to have the
      same index "attnum" as what we'd been scanning.  Since there's no
      physical separation of tuples with different attnums, it's not terribly
      hard to devise scenarios where this fails, leading to transient "lost
      saved point in index" errors.  (While I've duplicated this with manual
      testing, it seems impossible to make a reproducible test case with our
      available testing technology.)
      
      Fix by just continuing the scan when the attnum doesn't match.
      
      While here, improve the error message used if we do fail, so that it
      matches the wording used in btree for a similar case.
      
      collectMatchBitmap()'s posting-tree code path was previously not
      exercised at all by our regression tests.  While I can't make
      a regression test that exhibits the bug, I can at least improve
      the code coverage here, so do that.  The test case I made for this
      is an extension of one added by 4b754d6c, so it only works in
      HEAD and v13; didn't seem worth trying hard to back-patch it.
      
      Per bug #16595 from Jesse Kinkead.  This has been broken since
      multicolumn capability was added to GIN (commit 27cb66fd),
      so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/16595-633118be8eef9ce2@postgresql.org
      10564ee0
    • Michael Paquier's avatar
      Fix comment in procarray.c · 77c7267c
      Michael Paquier authored
      The description of GlobalVisDataRels was missing, GlobalVisCatalogRels
      being mentioned instead.
      
      Author: Jim Nasby
      Discussion: https://postgr.es/m/8e06c883-2858-1fd4-07c5-560c28b08dcd@amazon.com
      77c7267c
  5. 26 Aug, 2020 7 commits
  6. 25 Aug, 2020 3 commits
  7. 24 Aug, 2020 2 commits
  8. 22 Aug, 2020 4 commits
  9. 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