1. 25 Mar, 2021 11 commits
    • Alvaro Herrera's avatar
      ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY · 71f4c8c6
      Alvaro Herrera authored
      Allow a partition be detached from its partitioned table without
      blocking concurrent queries, by running in two transactions and only
      requiring ShareUpdateExclusive in the partitioned table.
      
      Because it runs in two transactions, it cannot be used in a transaction
      block.  This is the main reason to use dedicated syntax: so that users
      can choose to use the original mode if they need it.  But also, it
      doesn't work when a default partition exists (because an exclusive lock
      would still need to be obtained on it, in order to change its partition
      constraint.)
      
      In case the second transaction is cancelled or a crash occurs, there's
      ALTER TABLE .. DETACH PARTITION .. FINALIZE, which executes the final
      steps.
      
      The main trick to make this work is the addition of column
      pg_inherits.inhdetachpending, initially false; can only be set true in
      the first part of this command.  Once that is committed, concurrent
      transactions that use a PartitionDirectory will include or ignore
      partitions so marked: in optimizer they are ignored if the row is marked
      committed for the snapshot; in executor they are always included.  As a
      result, and because of the way PartitionDirectory caches partition
      descriptors, queries that were planned before the detach will see the
      rows in the detached partition and queries that are planned after the
      detach, won't.
      
      A CHECK constraint is created that duplicates the partition constraint.
      This is probably not strictly necessary, and some users will prefer to
      remove it afterwards, but if the partition is re-attached to a
      partitioned table, the constraint needn't be rechecked.
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Reviewed-by: default avatarAmit Langote <amitlangote09@gmail.com>
      Reviewed-by: default avatarJustin Pryzby <pryzby@telsasoft.com>
      Discussion: https://postgr.es/m/20200803234854.GA24158@alvherre.pgsql
      71f4c8c6
    • Alvaro Herrera's avatar
      Document lock obtained during partition detach · 650d6235
      Alvaro Herrera authored
      On partition detach, we acquire a SHARE lock on all tables that
      reference the partitioned table that we're detaching a partition from,
      but failed to document this fact.  My oversight in commit f56f8f8d.
      Repair.  Backpatch to 12.
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Discussion: https://postgr.es/m/20210325180244.GA12738@alvherre.pgsql
      650d6235
    • Alvaro Herrera's avatar
      Add comments for AlteredTableInfo->rel · cc121d55
      Alvaro Herrera authored
      The prior commit which introduced it was pretty squalid in terms of
      code documentation, so add some comments.
      cc121d55
    • Alvaro Herrera's avatar
      Let ALTER TABLE Phase 2 routines manage the relation pointer · cd03c6e9
      Alvaro Herrera authored
      Struct AlteredRelationInfo gains a new Relation member, to be used only
      by Phase 2 (ATRewriteCatalogs); this allows ATExecCmd() subroutines open
      and close the relation internally.
      
      A future commit will use this facility to implement an ALTER TABLE
      subcommand that closes and reopens the relation across transaction
      boundaries.
      
      (It is possible to keep the relation open past phase 2 to be used by
      phase 3 instead of having to reopen it that point, but there are some
      minor complications with that; it's not clear that there is much to be
      won from doing that, though.)
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Discussion: https://postgr.es/m/20200803234854.GA24158@alvherre.pgsql
      cd03c6e9
    • Alvaro Herrera's avatar
      Rework HeapTupleHeader macros to reuse itemptr.h · 4669cacb
      Alvaro Herrera authored
      The original definitions pointlessly disregarded existing ItemPointer
      macros that do the same thing.
      Reported-by: default avatarMichael Paquier <michael@paquier.xyz>
      Discussion: https://postgr.es/m/20210222201557.GA32655@alvherre.pgsql
      4669cacb
    • Alvaro Herrera's avatar
      Remove StoreSingleInheritance reimplementation · a24ae3d7
      Alvaro Herrera authored
      I introduced this duplicate code in commit 8b08f7d4 for no good
      reason.  Remove it, and backpatch to 11 where it was introduced.
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      a24ae3d7
    • Peter Eisentraut's avatar
      f2c7ce64
    • Peter Eisentraut's avatar
      Rename a parse node to be more general · 91d1f2d3
      Peter Eisentraut authored
      A WHERE clause will be used for row filtering in logical replication.
      We already have a similar node: 'WHERE (condition here)'.  Let's
      rename the node to a generic name and use it for row filtering too.
      
      Author: Euler Taveira <euler.taveira@enterprisedb.com>
      Discussion: https://www.postgresql.org/message-id/flat/CAHE3wggb715X+mK_DitLXF25B=jE6xyNCH4YOwM860JR7HarGQ@mail.gmail.com
      91d1f2d3
    • Michael Paquier's avatar
      Sanitize the term "combo CID" in code comments · a1999a01
      Michael Paquier authored
      Combo CIDs were referred in the code comments using different terms
      across various places of the code, so unify a bit the term used with
      what is currently in use in some of the READMEs.
      
      Author: "Hou, Zhijie"
      Discussion: https://postgr.es/m/1d42865c91404f46af4562532fdbea31@G08CNEXMBPEKD05.g08.fujitsu.local
      a1999a01
    • Fujii Masao's avatar
      Fix bug in WAL replay of COMMIT_TS_SETTS record. · 438fc4a3
      Fujii Masao authored
      Previously the WAL replay of COMMIT_TS_SETTS record called
      TransactionTreeSetCommitTsData() with the argument write_xlog=true,
      which generated and wrote new COMMIT_TS_SETTS record.
      This should not be acceptable because it's during recovery.
      
      This commit fixes the WAL replay of COMMIT_TS_SETTS record
      so that it calls TransactionTreeSetCommitTsData() with write_xlog=false
      and doesn't generate new WAL during recovery.
      
      Back-patch to all supported branches.
      Reported-by: default avatarlx zou <zoulx1982@163.com>
      Author: Fujii Masao
      Reviewed-by: Alvaro Herrera
      Discussion: https://postgr.es/m/16931-620d0f2fdc6108f1@postgresql.org
      438fc4a3
    • Fujii Masao's avatar
      Improve connection denied error message during recovery. · df938449
      Fujii Masao authored
      Previously when an archive recovery or a standby was starting and
      reached the consistent recovery state but hot_standby was configured
      to off, the error message when a client connectted was "the database
      system is starting up", which was needless confusing and not really
      all that accurate either.
      
      This commit improves the connection denied error message during
      recovery, as follows, so that the users immediately know that their
      servers are configured to deny those connections.
      
      - If hot_standby is disabled, the error message "the database system
        is not accepting connections" and the detail message "Hot standby
        mode is disabled." are output when clients connect while an archive
        recovery or a standby is running.
      
      - If hot_standby is enabled, the error message "the database system
        is not yet accepting connections" and the detail message
        "Consistent recovery state has not been yet reached." are output
        when clients connect until the consistent recovery state is reached
        and postmaster starts accepting read only connections.
      
      This commit doesn't change the connection denied error message of
      "the database system is starting up" during normal server startup and
      crash recovery. Because it's still suitable for those situations.
      
      Author: James Coleman
      Reviewed-by: Alvaro Herrera, Andres Freund, David Zhang, Tom Lane, Fujii Masao
      Discussion: https://postgr.es/m/CAAaqYe8h5ES_B=F_zDT+Nj9XU7YEwNhKhHA2RE4CFhAQ93hfig@mail.gmail.com
      df938449
  2. 24 Mar, 2021 13 commits
  3. 23 Mar, 2021 14 commits
  4. 22 Mar, 2021 2 commits