1. 09 Apr, 2019 4 commits
  2. 08 Apr, 2019 11 commits
  3. 07 Apr, 2019 5 commits
    • Tom Lane's avatar
      Avoid fetching past the end of the indoption array. · 80a96e06
      Tom Lane authored
      pg_get_indexdef_worker carelessly fetched indoption entries even for
      non-key index columns that don't have one.  99.999% of the time this
      would be harmless, since the code wouldn't examine the value ... but
      some fine day this will be a fetch off the end of memory, resulting
      in SIGSEGV.
      
      Detected through valgrind testing.  Odd that the buildfarm's valgrind
      critters haven't noticed.
      80a96e06
    • Alvaro Herrera's avatar
      psql \dP: list partitioned tables and indexes · 1c5d9270
      Alvaro Herrera authored
      The new command lists partitioned relations (tables and/or indexes),
      possibly with their sizes, possibly including partitioned partitions;
      their parents (if not top-level); if indexes show the tables they belong
      to; and their descriptions.
      
      While there are various possible improvements to this, having it in this
      form is already a great improvement over not having any way to obtain
      this report.
      
      Author: Pavel Stěhule, with help from Mathias Brossard, Amit Langote and
      	Justin Pryzby.
      Reviewed-by: Amit Langote, Mathias Brossard, Melanie Plageman,
      	Michaël Paquier, Álvaro Herrera
      1c5d9270
    • Tom Lane's avatar
      Clean up side-effects of commits ab5fcf2b et al. · 159970bc
      Tom Lane authored
      Before those commits, partitioning-related code in the executor could
      assume that ModifyTableState.resultRelInfo[] contains only leaf partitions.
      However, now a fully-pruned update results in a dummy ModifyTable that
      references the root partitioned table, and that breaks some stuff.
      
      In v11, this led to an assertion or core dump in the tuple routing code.
      Fix by disabling tuple routing, since we don't need that anyway.
      (I chose to do that in HEAD as well for safety, even though the problem
      doesn't manifest in HEAD as it stands.)
      
      In v10, this confused ExecInitModifyTable's decision about whether it
      needed to close the root table.  But we can get rid of that altogether
      by being smarter about where to find the root table.
      
      Note that since the referenced commits haven't shipped yet, this
      isn't fixing any bug the field has seen.
      
      Amit Langote, per a report from me
      
      Discussion: https://postgr.es/m/20710.1554582479@sss.pgh.pa.us
      159970bc
    • Peter Eisentraut's avatar
      Report progress of REINDEX operations · 03f9e5cb
      Peter Eisentraut authored
      This uses the same infrastructure that the CREATE INDEX progress
      reporting uses.  Add a column to pg_stat_progress_create_index to
      report the OID of the index being worked on.  This was not necessary
      for CREATE INDEX, but it's useful for REINDEX.
      
      Also edit the phase descriptions a bit to be more consistent with the
      source code comments.
      
      Discussion: https://www.postgresql.org/message-id/ef6a6757-c36a-9e81-123f-13b19e36b7d7%402ndquadrant.com
      03f9e5cb
    • Peter Eisentraut's avatar
      Cast pg_stat_progress_cluster.cluster_index_relid to oid · 106f2eb6
      Peter Eisentraut authored
      It's tracked internally as bigint, but when presented to the user it
      should be oid.
      106f2eb6
  4. 06 Apr, 2019 3 commits
  5. 05 Apr, 2019 15 commits
    • Tom Lane's avatar
      Use Append rather than MergeAppend for scanning ordered partitions. · 959d00e9
      Tom Lane authored
      If we need ordered output from a scan of a partitioned table, but
      the ordering matches the partition ordering, then we don't need to
      use a MergeAppend to combine the pre-ordered per-partition scan
      results: a plain Append will produce the same results.  This
      both saves useless comparison work inside the MergeAppend proper,
      and allows us to start returning tuples after istarting up just
      the first child node not all of them.
      
      However, all is not peaches and cream, because if some of the
      child nodes have high startup costs then there will be big
      discontinuities in the tuples-returned-versus-elapsed-time curve.
      The planner's cost model cannot handle that (yet, anyway).
      If we model the Append's startup cost as being just the first
      child's startup cost, we may drastically underestimate the cost
      of fetching slightly more tuples than are available from the first
      child.  Since we've had bad experiences with over-optimistic choices
      of "fast start" plans for ORDER BY LIMIT queries, that seems scary.
      As a klugy workaround, set the startup cost estimate for an ordered
      Append to be the sum of its children's startup costs (as MergeAppend
      would).  This doesn't really describe reality, but it's less likely
      to cause a bad plan choice than an underestimated startup cost would.
      In practice, the cases where we really care about this optimization
      will have child plans that are IndexScans with zero startup cost,
      so that the overly conservative estimate is still just zero.
      
      David Rowley, reviewed by Julien Rouhaud and Antonin Houska
      
      Discussion: https://postgr.es/m/CAKJS1f-hAqhPLRk_RaSFTgYxd=Tz5hA7kQ2h4-DhJufQk8TGuw@mail.gmail.com
      959d00e9
    • Alvaro Herrera's avatar
      Add facility to copy replication slots · 9f06d79e
      Alvaro Herrera authored
      This allows the user to create duplicates of existing replication slots,
      either logical or physical, and even changing properties such as whether
      they are temporary or the output plugin used.
      
      There are multiple uses for this, such as initializing multiple replicas
      using the slot for one base backup; when doing investigation of logical
      replication issues; and to select a different output plugins.
      
      Author: Masahiko Sawada
      Reviewed-by: Michael Paquier, Andres Freund, Petr Jelinek
      Discussion: https://postgr.es/m/CAD21AoAm7XX8y_tOPP6j4Nzzch12FvA1wPqiO690RCk+uYVstg@mail.gmail.com
      9f06d79e
    • Thomas Munro's avatar
      Wake up interested backends when a checkpoint fails. · de2b3841
      Thomas Munro authored
      Commit c6c9474a switched to condition variables instead of sleep
      loops to notify backends of checkpoint start and stop, but forgot
      to broadcast in case of checkpoint failure.
      
      Author: Thomas Munro
      Discussion: https://postgr.es/m/CA%2BhUKGJKbCd%2B_K%2BSEBsbHxVT60SG0ivWHHAdvL0bLTUt2xpA2w%40mail.gmail.com
      de2b3841
    • Robert Haas's avatar
      Fix missing word. · 6665305e
      Robert Haas authored
      Nathan Bossart
      
      Discussion: http://postgr.es/m/2C63765B-AD31-4F6C-8DA7-C8544634C714@amazon.com
      6665305e
    • Tom Lane's avatar
      Ensure consistent name matching behavior in processSQLNamePattern(). · 478cacb5
      Tom Lane authored
      Prior to v12, if you used a collation-sensitive regex feature in a
      pattern handled by processSQLNamePattern() (for instance, \d '\\w+'
      in psql), the behavior you got matched the database's default collation.
      Since commit 586b98fd you'd usually get C-collation behavior, because
      the catalog "name"-type columns are now marked as COLLATE "C".  Add
      explicit COLLATE specifications to restore the prior behavior.
      
      (Note for whoever writes the v12 release notes: the need for this shows
      that while 586b98fd preserved pre-v12 behavior of "name" columns for
      simple comparison operators, it changed the behavior of regex operators
      on those columns.  Although this patch fixes it for pattern matches
      generated by our own tools, user-written queries will still be affected.
      So we'd better mention this issue as a compatibility item.)
      
      Daniel Vérité
      
      Discussion: https://postgr.es/m/701e51f0-0ec0-4e70-a365-1958d66dd8d2@manitou-mail.org
      478cacb5
    • Andres Freund's avatar
      table: docs: fix typos and grammar. · 86cc06d1
      Andres Freund authored
      Author: Justin Pryzby
      Discussion: https://postgr.es/m/20190404055138.GA24864@telsasoft.com
      86cc06d1
    • Etsuro Fujita's avatar
      Doc: Update documentation on partitioning vs. foreign tables. · 3e6b0c47
      Etsuro Fujita authored
      The limitations that it is not allowed to create/attach a foreign table
      as a partition of an indexed partitioned table were not documented.
      
      Reported-By: Stepan Yankevych
      Author: Etsuro Fujita
      Reviewed-By: Amit Langote
      Backpatch-through: 11 where partitioned index was introduced
      Discussion: https://postgr.es/m/1553869152.858391073.5f8m3n0x@frv53.fwdcdn.com
      3e6b0c47
    • Peter Eisentraut's avatar
      Fix compiler warning · edda32ee
      Peter Eisentraut authored
      Rewrite get_attgenerated() to avoid compiler warning if the compiler
      does not recognize that elog(ERROR) does not return.
      Reported-by: default avatarDavid Rowley <david.rowley@2ndquadrant.com>
      edda32ee
    • Noah Misch's avatar
      Revert "Consistently test for in-use shared memory." · 82150a05
      Noah Misch authored
      This reverts commits 2f932f71,
      16ee6eaf and
      6f0e1900.  The buildfarm has revealed
      several bugs.  Back-patch like the original commits.
      
      Discussion: https://postgr.es/m/20190404145319.GA1720877@rfd.leadboat.com
      82150a05
    • Thomas Munro's avatar
      Fix bugs in mdsyncfiletag(). · 794c543b
      Thomas Munro authored
      Commit 3eb77eba moved a _mdfd_getseg() call from mdsync() into a new
      callback function mdsyncfiletag(), but didn't get the arguments quite
      right.  Without the EXTENSION_DONT_CHECK_SIZE flag we fail to open a
      segment if lower-numbered segments have been truncated, and it wants
      a block number rather than a segment number.
      
      While comparing with the older coding, also remove an unnecessary
      clobbering of errno, and adjust the code in mdunlinkfiletag() to
      ressemble the original code from mdpostckpt() more closely instead
      of using an unnecessary call to smgropen().
      
      Author: Thomas Munro
      Discussion: https://postgr.es/m/CA%2BhUKGL%2BYLUOA0eYiBXBfwW%2BbH5kFgh94%3DgQH0jHEJ-t5Y91wQ%40mail.gmail.com
      794c543b
    • Stephen Frost's avatar
      Handle errors during GSSAPI startup better · c46c85d4
      Stephen Frost authored
      There was some confusion over the format of the error message returned
      from the server during GSSAPI startup; specifically, it was expected
      that a length would be returned when, in reality, at this early stage in
      the startup sequence, no length is returned from the server as part of
      an error message.
      
      Correct the client-side code for dealing with error messages sent by the
      server during startup by simply reading what's available into our
      buffer, after we've discovered it's an error message, and then reporting
      back what was returned.
      
      In passing, also add in documentation of the environment variable
      PGGSSENCMODE which was missed previously, and adjust the code to look
      for the PGGSSENCMODE variable (the environment variable change was
      missed in the prior GSSMODE -> GSSENCMODE commit).
      
      Error-handling issue discovered by Peter Eisentraut, the rest were items
      discovered during testing of the error handling.
      c46c85d4
    • Michael Paquier's avatar
      Fix some documentation in pg_rewind · bfc80683
      Michael Paquier authored
      Since 11, it is possible to use a non-superuser role when using an
      online source cluster with pg_rewind as long as the role has proper
      permissions to execute on the source all the functions used by
      pg_rewind, and the documentation stated that a superuser is necessary.
      Let's add at the same time all the details needed to create such a
      role.
      
      A second confusion which comes a lot from users is that it is necessary
      to issue a checkpoint on a freshly-promoted standby so as its control
      file has up-to-date timeline information which is used by pg_rewind to
      validate the operation.  Let's document that properly.  This is
      back-patched down to 9.5 where pg_rewind has been introduced.
      
      Author: Michael Paquier
      Reviewed-by: Magnus Hagander
      Discussion: https://postgr.es/m/CABUevEz5bpvbwVsYCaSMV80CBZ5-82nkMzbb+Bu=h1m=rLdn=g@mail.gmail.com
      Backpatch-through: 9.5
      bfc80683
    • Andres Freund's avatar
    • Andres Freund's avatar
      Harden tableam against nonexistant / wrong kind of AMs. · ea97e440
      Andres Freund authored
      Previously it was allowed to set default_table_access_method to an
      empty string. That makes sense for default_tablespace, where that was
      copied from, as it signals falling back to the database's default
      tablespace. As there is no equivalent for table AMs, forbid that.
      
      Also make sure to throw a usable error when creating a table using an
      index AM, by using get_am_type_oid() to implement get_table_am_oid()
      instead of a separate copy. Previously we'd error out only later, in
      GetTableAmRoutine().
      
      Thirdly remove GetTableAmRoutineByAmId() - it was only used in an
      earlier version of 8586bf7e.
      
      Add tests for the above (some for index AMs as well).
      ea97e440
    • Peter Geoghegan's avatar
      Add test coverage for rootdescend verification. · 344b7e11
      Peter Geoghegan authored
      Commit c1afd175, which added support for rootdescend verification to
      amcheck, added only minimal regression test coverage.  Address this by
      making sure that rootdescend verification is run on a multi-level index.
      In passing, simplify some of the regression tests that exercise
      multi-level nbtree page deletion.
      
      Both issues spotted while rereviewing coverage of the nbtree patch
      series using gcov.
      344b7e11
  6. 04 Apr, 2019 2 commits
    • Andres Freund's avatar
      tableam: Add table_multi_insert() and revamp/speed-up COPY FROM buffering. · 86b85044
      Andres Freund authored
      This adds table_multi_insert(), and converts COPY FROM, the only user
      of heap_multi_insert, to it.
      
      A simple conversion of COPY FROM use slots would have yielded a
      slowdown when inserting into a partitioned table for some
      workloads. Different partitions might need different slots (both slot
      types and their descriptors), and dropping / creating slots when
      there's constant partition changes is measurable.
      
      Thus instead revamp the COPY FROM buffering for partitioned tables to
      allow to buffer inserts into multiple tables, flushing only when
      limits are reached across all partition buffers. By only dropping
      slots when there've been inserts into too many different partitions,
      the aforementioned overhead is gone. By allowing larger batches, even
      when there are frequent partition changes, we actuall speed such cases
      up significantly.
      
      By using slots COPY of very narrow rows into unlogged / temporary
      might slow down very slightly (due to the indirect function calls).
      
      Author: David Rowley, Andres Freund, Haribabu Kommi
      Discussion:
          https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
          https://postgr.es/m/20190327054923.t3epfuewxfqdt22e@alap3.anarazel.de
      86b85044
    • Tom Lane's avatar
      Add a "SQLSTATE-only" error verbosity option to libpq and psql. · 7bac3aca
      Tom Lane authored
      This is intended for use mostly in test scripts for external tools,
      which could do without cross-PG-version variations in error message
      wording.  Of course, the SQLSTATE isn't guaranteed stable either, but
      it should be more so than the error message text.
      
      Note: there's a bit of an ABI change for libpq here, but it seems
      OK because if somebody compiles against a newer version of libpq-fe.h,
      and then tries to pass PQERRORS_SQLSTATE to PQsetErrorVerbosity()
      of an older libpq library, it will be accepted and then act like
      PQERRORS_DEFAULT, thanks to the way the tests in pqBuildErrorMessage3
      have historically been phrased.  That seems acceptable.
      
      Didier Gautheron, reviewed by Dagfinn Ilmari Mannsåker
      
      Discussion: https://postgr.es/m/CAJRYxuKyj4zA+JGVrtx8OWAuBfE-_wN4sUMK4H49EuPed=mOBw@mail.gmail.com
      7bac3aca