1. 10 Mar, 2020 6 commits
  2. 09 Mar, 2020 8 commits
    • Tom Lane's avatar
      Fix pg_dump/pg_restore to restore event triggers later. · 8728b2c7
      Tom Lane authored
      Previously, event triggers were restored just after regular triggers
      (and FK constraints, which are basically triggers).  This is risky
      since an event trigger, once installed, could interfere with subsequent
      restore commands.  Worse, because event triggers don't have any
      particular dependencies on any post-data objects, a parallel restore
      would consider them eligible to be restored the moment the post-data
      phase starts, allowing them to also interfere with restoration of a
      whole bunch of objects that would have been restored before them in
      a serial restore.  There's no way to completely remove the risk of a
      misguided event trigger breaking the restore, since if nothing else
      it could break other event triggers.  But we can certainly push them
      to later in the process to minimize the hazard.
      
      To fix, tweak the RestorePass mechanism introduced by commit 3eb9a5e7
      so that event triggers are handled as part of the post-ACL processing
      pass (renaming the "REFRESH" pass to "POST_ACL" to reflect its more
      general use).  This will cause them to restore after everything except
      matview refreshes, which seems OK since matview refreshes really ought
      to run in the post-restore state of the database.  In a parallel
      restore, event triggers and matview refreshes might be intermixed,
      but that seems all right as well.
      
      Also update the code and comments in pg_dump_sort.c so that its idea
      of how things are sorted agrees with what actually happens due to
      the RestorePass mechanism.  This is mostly cosmetic: it'll affect the
      order of objects in a dump's TOC, but not the actual restore order.
      But not changing that would be quite confusing to somebody reading
      the code.
      
      Back-patch to all supported branches.
      
      Fabrízio de Royes Mello, tweaked a bit by me
      
      Discussion: https://postgr.es/m/CAFcNs+ow1hmFox8P--3GSdtwz-S3Binb6ZmoP6Vk+Xg=K6eZNA@mail.gmail.com
      8728b2c7
    • Jeff Davis's avatar
      Introduce LogicalTapeSetExtend(). · 24d85952
      Jeff Davis authored
      Increases the number of tapes in a logical tape set. This will be
      important for disk-based hash aggregation, because the maximum number
      of tapes is not known ahead of time.
      
      While discussing this change, it was observed to regress the
      performance of Sort for at least one test case. The performance
      regression was because some versions of GCC switch to an inlined
      version of memcpy() in LogicalTapeWrite() after this change. No
      performance regression for clang was observed.
      
      Because the regression is due to an arbitrary decision by the
      compiler, I decided it shouldn't hold up this change. If it needs to
      be fixed, we can find a workaround.
      
      Author: Adam Lee, Jeff Davis
      Discussion: https://postgr.es/m/e54bfec11c59689890f277722aaaabd05f78e22c.camel%40j-davis.com
      24d85952
    • Fujii Masao's avatar
      Fix bug that causes to report waiting in PS display twice, in hot standby. · 17d3fcdc
      Fujii Masao authored
      Previously "waiting" could appear twice via PS in case of lock conflict
      in hot standby mode. Specifically this issue happend when the delay
      in WAL application determined by max_standby_archive_delay and
      max_standby_streaming_delay had passed but it took more than 500 msec
      to cancel all the conflicting transactions. Especially we can observe this
      easily by setting those delay parameters to -1.
      
      The cause of this issue was that WaitOnLock() and
      ResolveRecoveryConflictWithVirtualXIDs() added "waiting" to
      the process title in that case. This commit prevents
      ResolveRecoveryConflictWithVirtualXIDs() from reporting waiting
      in case of lock conflict, to fix the bug.
      
      Back-patch to all back branches.
      
      Author: Masahiko Sawada
      Reviewed-by: Fujii Masao
      Discussion: https://postgr.es/m/CA+fd4k4mXWTwfQLS3RPwGr4xnfAEs1ysFfgYHvmmoUgv6Zxvmg@mail.gmail.com
      17d3fcdc
    • Peter Eisentraut's avatar
      Add tg_updatedcols to TriggerData · 71d60e2a
      Peter Eisentraut authored
      This allows a trigger function to determine for an UPDATE trigger
      which columns were actually updated.  This allows some optimizations
      in generic trigger functions such as lo_manage and
      tsvector_update_trigger.
      Reviewed-by: default avatarDaniel Gustafsson <daniel@yesql.se>
      Discussion: https://www.postgresql.org/message-id/flat/11c5f156-67a9-0fb5-8200-2a8018eb2e0c@2ndquadrant.com
      71d60e2a
    • Peter Eisentraut's avatar
      Code simplification · 8f152b6c
      Peter Eisentraut authored
      Initialize TriggerData to 0 for the whole struct together, instead of
      each field separately.
      Reviewed-by: default avatarDaniel Gustafsson <daniel@yesql.se>
      Discussion: https://www.postgresql.org/message-id/flat/11c5f156-67a9-0fb5-8200-2a8018eb2e0c@2ndquadrant.com
      8f152b6c
    • Fujii Masao's avatar
      Avoid assertion failure with targeted recovery in standby mode. · ef34ab42
      Fujii Masao authored
      At the end of recovery, standby mode is turned off to re-fetch the last
      valid record from archive or pg_wal. Previously, if recovery target was
      reached and standby mode was turned off while the current WAL source
      was stream, recovery could try to retrieve WAL file containing the last
      valid record unexpectedly from stream even though not in standby mode.
      This caused an assertion failure. That is, the assertion test confirms that
      WAL file should not be retrieved from stream if standby mode is not true.
      
      This commit moves back the current WAL source to archive if it's stream
      even though not in standby mode, to avoid that assertion failure.
      
      This issue doesn't cause the server to crash when built with assertion
      disabled. In this case, the attempt to retrieve WAL file from stream not
      in standby mode just fails. And then recovery tries to retrieve WAL file
      from archive or pg_wal.
      
      Back-patch to all supported branches.
      
      Author: Kyotaro Horiguchi
      Reviewed-by: Fujii Masao
      Discussion: https://postgr.es/m/20200227.124830.2197604521555566121.horikyota.ntt@gmail.com
      ef34ab42
    • Fujii Masao's avatar
      Mark ssl_passphrase_command as GUC_SUPERUSER_ONLY. · d9249441
      Fujii Masao authored
      This commit changes the GUC ssl_passphrase_command so that
      it's examinable by only superuser and a member of pg_read_all_settings.
      Per discussion, we determined to do this because the parameter may
      contain a sensitive informtaion like a passphrase itself.
      
      Author: Insung Moon
      Reviewed-by: Keisuke Kuroda
      Discussion: https://postgr.es/m/CAEMmqBuHVGayc+QkYKgx3gWSdqwTAQGw+0DYn3WhcX-eNa2ntA@mail.gmail.com
      d9249441
    • Michael Paquier's avatar
      Doc: fix some description of environment variables with frontend tools · 5aaa584f
      Michael Paquier authored
      This addresses a couple of issues in the documentation:
      - Description of PG_COLOR was missing for some tools (pg_archivecleanup
      and pg_test_fsync), while the other descriptions had grammar mistakes.
      - pgbench supports more environment variables: PGUSER, PGHOST and
      PGPORT.
      - vacuumlo, oid2name and pgbench support coloring (HEAD only)
      
      Author: Michael Paquier
      Reviewed-by: Fabien Coelho, Daniel Gustafsson, Juan José Santamaría
      Flecha
      Discussion: https://postgr.es/m/20200304075418.GJ2593@paquier.xyz
      Backpatch-through: 12
      5aaa584f
  3. 08 Mar, 2020 4 commits
    • Tom Lane's avatar
    • Tom Lane's avatar
      Add an explicit test to catch changes in checksumming calculations. · 38ce06c3
      Tom Lane authored
      Seems like a good idea in view of 00651743 and addd034a.
      
      Michael Paquier, Tom Lane
      
      Discussion: https://postgr.es/m/20200306075230.GA118430@paquier.xyz
      38ce06c3
    • Alexander Korotkov's avatar
      Show opclass and opfamily related information in psql · b0b5e20c
      Alexander Korotkov authored
      This commit provides psql commands for listing operator classes, operator
      families and its contents in psql.  New commands will be useful for exploring
      capabilities of both builtin opclasses/opfamilies as well as
      opclasses/opfamilies defined in extensions.
      
      Discussion: https://postgr.es/m/1529675324.14193.5.camel%40postgrespro.ru
      Author: Sergey Cherkashin, Nikita Glukhov, Alexander Korotkov
      Reviewed-by: Michael Paquier, Alvaro Herrera, Arthur Zakirov
      Reviewed-by: Kyotaro Horiguchi, Andres Freund
      b0b5e20c
    • Peter Geoghegan's avatar
      pageinspect: Fix types used for bt_metap() columns. · 691e8b2e
      Peter Geoghegan authored
      The data types that contrib/pageinspect's bt_metap() function were
      declared to return as OUT arguments were wrong in some cases.  For
      example, the oldest_xact column (a TransactionId/xid field) was declared
      integer/int4 within the pageinspect extension's sql file.  This led to
      errors when an oldest_xact value that exceeded 2^31-1 was encountered.
      Some of the other columns were defined incorrectly ever since
      pageinspect was first introduced, though they were far less likely to
      produce problems in practice.
      
      Fix these issues by changing the declaration of bt_metap() to
      consistently use data types that can reliably represent all possible
      values.  This fixes things on HEAD only.  No backpatch, since it doesn't
      seem like there is a safe way to fix the issue without including a new
      version of the pageinspect extension (HEAD/Postgres 13 already
      introduced a new version of the extension).  Besides, the oldest_xact
      issue has been around since the release of Postgres 11, and we haven't
      heard any complaints about it before now.
      
      Also, throw an error when we detect a bt_metap() declaration that must
      be from an old version of the pageinspect extension by examining the
      number of attributes from the tuple descriptor for the return tuples.
      It seems better to throw an error in a reliable and obvious way
      following a Postgres upgrade, rather than letting bt_metap() fail
      unpredictably.  The problem is fundamentally with the CREATE FUNCTION
      declared data types themselves, so I see no sensible alternative.
      
      Reported-By: Victor Yegorov
      Bug: #16285
      Discussion: https://postgr.es/m/16285-df8fc1000ab3d5fc@postgresql.org
      691e8b2e
  4. 07 Mar, 2020 5 commits
  5. 06 Mar, 2020 3 commits
    • Tom Lane's avatar
      Create contrib/bool_plperl to provide a bool transform for PL/Perl[U]. · 36058a3c
      Tom Lane authored
      plperl's default handling of bool arguments or results is not terribly
      satisfactory, since Perl doesn't consider the string 'f' to be false.
      Ideally we'd just fix that, but the backwards-compatibility hazard
      would be substantial.  Instead, build a TRANSFORM module that can
      be optionally applied to provide saner semantics.
      
      Perhaps usefully, this is also about the minimum possible skeletal
      example of a plperl transform module; so it might be a better starting
      point for user-written transform modules than hstore_plperl or
      jsonb_plperl.
      
      Ivan Panchenko
      
      Discussion: https://postgr.es/m/1583013317.881182688@f390.i.mail.ru
      36058a3c
    • Tom Lane's avatar
      Allow Unicode escapes in any server encoding, not only UTF-8. · a6525588
      Tom Lane authored
      SQL includes provisions for numeric Unicode escapes in string
      literals and identifiers.  Previously we only accepted those
      if they represented ASCII characters or the server encoding
      was UTF-8, making the conversion to internal form trivial.
      This patch adjusts things so that we'll call the appropriate
      encoding conversion function in less-trivial cases, allowing
      the escape sequence to be accepted so long as it corresponds
      to some character available in the server encoding.
      
      This also applies to processing of Unicode escapes in JSONB.
      However, the old restriction still applies to client-side
      JSON processing, since that hasn't got access to the server's
      encoding conversion infrastructure.
      
      This patch includes some lexer infrastructure that simplifies
      throwing errors with error cursors pointing into the middle of
      a string (or other complex token).  For the moment I only used
      it for errors relating to Unicode escapes, but we might later
      expand the usage to some other cases.
      
      Patch by me, reviewed by John Naylor.
      
      Discussion: https://postgr.es/m/2393.1578958316@sss.pgh.pa.us
      a6525588
    • Tom Lane's avatar
      Allow ALTER TYPE to change some properties of a base type. · fe30e7eb
      Tom Lane authored
      Specifically, this patch allows ALTER TYPE to:
      * Change the default TOAST strategy for a toastable base type;
      * Promote a non-toastable type to toastable;
      * Add/remove binary I/O functions for a type;
      * Add/remove typmod I/O functions for a type;
      * Add/remove a custom ANALYZE statistics functions for a type.
      
      The first of these can be done by the type's owner; all the others
      require superuser privilege since misuse could cause problems.
      
      The main motivation for this patch is to allow extensions to
      upgrade the feature sets of their data types, so the set of
      alterable properties is biased towards that use-case.  However
      it's also true that changing some other properties would be
      a lot harder, as they get baked into physical storage and/or
      stored expressions that depend on the type.
      
      Along the way, refactor GenerateTypeDependencies() to make it easier
      to call, refactor DefineType's volatility checks so they can be shared
      by AlterType, and teach typcache.c that it might have to reload data
      from the type's pg_type row, a scenario it never handled before.
      Also rearrange alter_type.sgml a bit for clarity (put the
      composite-type operations together).
      
      Tomas Vondra and Tom Lane
      
      Discussion: https://postgr.es/m/20200228004440.b23ein4qvmxnlpht@development
      fe30e7eb
  6. 05 Mar, 2020 9 commits
    • Michael Paquier's avatar
      Fix page-level checksum calculation in checksum_impl.h · addd034a
      Michael Paquier authored
      Issue introduced by me, as of 00651743.
      
      Reported-by: David Steele
      Discussion: https://postgr.es/m/1cf30561-7dad-dc6e-9fc3-5c456948cfeb@pgmasters.net
      addd034a
    • Tom Lane's avatar
      Remove the "opaque" pseudo-type and associated compatibility hacks. · bb03010b
      Tom Lane authored
      A long time ago, it was necessary to declare datatype I/O functions,
      triggers, and language handler support functions in a very type-unsafe
      way involving a single pseudo-type "opaque".  We got rid of those
      conventions in 7.3, but there was still support in various places to
      automatically convert such functions to the modern declaration style,
      to be able to transparently re-load dumps from pre-7.3 servers.
      It seems unnecessary to continue to support that anymore, so take out
      the hacks; whereupon the "opaque" pseudo-type itself is no longer
      needed and can be dropped.
      
      This is part of a group of patches removing various server-side kluges
      for transparently upgrading pre-8.0 dump files.  Since we've had few
      complaints about dropping pg_dump's support for dumping from pre-8.0
      servers (commit 64f3524e), it seems okay to now remove these kluges.
      
      Discussion: https://postgr.es/m/4110.1583255415@sss.pgh.pa.us
      bb03010b
    • Tom Lane's avatar
      Remove ancient hacks to ignore certain opclass names in CREATE INDEX. · 84eca14b
      Tom Lane authored
      Twenty years ago, we removed certain operator classes in favor of
      letting indexes over their data types be built with some other
      binary-compatible, more standard opclass.  As a hack to allow existing
      index definitions to be dumped and reloaded, we made CREATE INDEX ignore
      the removed opclass names, so that such indexes would fall back to the
      new default opclass for their data types.  This was never intended to
      be a long-lived thing; it carries the obvious risk of breaking some
      future developer's attempt to re-use those old opclass names.  Since
      all of the cases in question are for opclasses that were removed
      before PG 8.0, it seems okay to get rid of these hacks now.
      
      This is part of a group of patches removing various server-side kluges
      for transparently upgrading pre-8.0 dump files.  Since we've had few
      complaints about dropping pg_dump's support for dumping from pre-8.0
      servers (commit 64f3524e), it seems okay to now remove these kluges.
      
      Discussion: https://postgr.es/m/3685.1583422389@sss.pgh.pa.us
      84eca14b
    • Tom Lane's avatar
      Remove ancient support for upgrading pre-7.3 foreign key constraints. · e58a5997
      Tom Lane authored
      Before 7.3, foreign key constraints had no explicit catalog
      representation, so that what pg_dump produced for them was (usually)
      a set of three CREATE CONSTRAINT TRIGGER commands.  Commit a2899ebd
      and some follow-on fixes added an ugly hack in CreateTrigger() to
      recognize that pattern and reconstruct the foreign key definition.
      However, we've never had any test coverage for that code, so that it's
      legitimate to wonder if it still works; and having to maintain it in
      the face of upcoming trigger-related patches seems rather pointless.
      Let's decree that its time has passed, and drop it.
      
      This is part of a group of patches removing various server-side kluges
      for transparently upgrading pre-8.0 dump files.  Since we've had few
      complaints about dropping pg_dump's support for dumping from pre-8.0
      servers (commit 64f3524e), it seems okay to now remove these kluges.
      
      Daniel Gustafsson
      
      Discussion: https://postgr.es/m/805874E2-999C-4CDA-856F-1AFBD9DFE933@yesql.se
      e58a5997
    • Alvaro Herrera's avatar
      Remove RangeIOData->typiofunc · a77315fd
      Alvaro Herrera authored
      We used to carry the I/O function OID in RangeIOData, but it's not used
      for anything.  Since the struct is not exposed to the world anyway, we
      can simplify it a bit.  Also, rename the FmgrInfo member to match
      the accompanying 'typioparam' and put them in a more sensible order.
      
      Reviewed by Tom Lane and Paul Jungwirth.
      
      Discussion: https://postgr.es/m/20200304215711.GA8732@alvherre.pgsql
      a77315fd
    • Michael Paquier's avatar
      Avoid -Wconversion warnings when using checksum_impl.h · 00651743
      Michael Paquier authored
      This does not matter much when compiling Postgres proper as many
      warnings exist when enabling this compilation flag, but it can be
      annoying for external modules willing to use both.
      
      Author: David Steele
      Discussion: https://postgr.es/m/91d86c8a-11fc-7b88-43eb-5ca3f6fb8bd3@pgmasters.net
      00651743
    • Fujii Masao's avatar
      Fix issues around .pgpass file. · 2eb3bc58
      Fujii Masao authored
      This commit fixes the following two issues around .pgpass file.
      
      (1) If the length of a line in .pgpass file was larger than 319B,
              libpq silently treated each 319B in the line as a separate
              setting line.
      
      (2) The document explains that a line beginning with # is treated
              as a comment in .pgpass. But there was no code doing such
              special handling. Whether a line begins with # or not, libpq
              just checked that the first token in the line match with the host.
      
      For (1), this commit makes libpq warn if the length of a line
      is larger than 319B, and throw away the remaining part beginning
      from 320B position.
      
      For (2), this commit changes libpq so that it treats any lines
      beginning with # as comments.
      
      Author: Fujii Masao
      Reviewed-by: Hamid Akhtar
      Discussion: https://postgr.es/m/c0f0c01c-fa74-9749-2084-b73882fd5465@oss.nttdata.com
      2eb3bc58
    • Michael Paquier's avatar
      Fix more issues with dependency handling at swap phase of REINDEX CONCURRENTLY · fbcf0871
      Michael Paquier authored
      When canceling a REINDEX CONCURRENTLY operation after swapping is done,
      a drop of the parent table would leave behind old indexes.  This is a
      consequence of 68ac9cf2, which fixed the case of pg_depend bloat when
      repeating REINDEX CONCURRENTLY on the same relation.
      
      In order to take care of the problem without breaking the previous fix,
      this uses a different strategy, possible even with the exiting set of
      routines to handle dependency changes.  The dependencies of/on the
      new index are additionally switched to the old one, allowing an old
      invalid index remaining around because of a cancellation or a failure to
      use the dependency links of the concurrently-created index.  This
      ensures that dropping any objects the old invalid index depends on also
      drops the old index automatically.
      
      Reported-by: Julien Rouhaud
      Author: Michael Paquier
      Reviewed-by: Julien Rouhaud
      Discussion: https://postgr.es/m/20200227080735.l32fqcauy73lon7o@nol
      Backpatch-through: 12
      fbcf0871
    • Jeff Davis's avatar
      Extend ExecBuildAggTrans() to support a NULL pointer check. · c954d490
      Jeff Davis authored
      Optionally push a step to check for a NULL pointer to the pergroup
      state.
      
      This will be important for disk-based hash aggregation in combination
      with grouping sets. When memory limits are reached, a given tuple may
      find its per-group state for some grouping sets but not others. For
      the former, it advances the per-group state as normal; for the latter,
      it skips evaluation and the calling code will have to spill the tuple
      and reprocess it in a later batch.
      
      Add the NULL check as a separate expression step because in some
      common cases it's not needed.
      
      Discussion: https://postgr.es/m/20200221202212.ssb2qpmdgrnx52sj%40alap3.anarazel.de
      c954d490
  7. 04 Mar, 2020 2 commits
  8. 03 Mar, 2020 3 commits