1. 01 Mar, 2019 5 commits
    • Andres Freund's avatar
      Store tuples for EvalPlanQual in slots, rather than as HeapTuples. · ad0bda5d
      Andres Freund authored
      For the upcoming pluggable table access methods it's quite
      inconvenient to store tuples as HeapTuples, as that'd require
      converting tuples from a their native format into HeapTuples. Instead
      use slots to manage epq tuples.
      
      To fit into that scheme, change the foreign data wrapper callback
      RefetchForeignRow, to store the tuple in a slot. Insist on using the
      caller provided slot, so it conveniently can be stored in the
      corresponding EPQ slot.  As there is no in core user of
      RefetchForeignRow, that change was done blindly, but we plan to test
      that soon.
      
      To avoid duplicating that work for row locks, move row locks to just
      directly use the EPQ slots - it previously temporarily stored tuples
      in LockRowsState.lr_curtuples, but that doesn't seem beneficial, given
      we'd possibly end up with a significant number of additional slots.
      
      The behaviour of es_epqTupleSet[rti -1] is now checked by
      es_epqTupleSlot[rti -1] != NULL, as that is distinguishable from a
      slot containing an empty tuple.
      
      Author: Andres Freund, Haribabu Kommi, Ashutosh Bapat
      Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
      ad0bda5d
    • Andrew Dunstan's avatar
      Add extra descriptive headings in pg_dumpall · 6cbdbd9e
      Andrew Dunstan authored
      Headings are added for the User Configurations and Databases sections,
      and for each user configuration and database in the output.
      
      Author: Fabien Coelho
      Discussion: https://postgr.es/m/alpine.DEB.2.21.1812272222130.32444@lancre
      6cbdbd9e
    • Andrew Dunstan's avatar
      Add --exclude-database option to pg_dumpall · f092de05
      Andrew Dunstan authored
      This option functions similarly to pg_dump's --exclude-table option, but
      for database names. The option can be given once, and the argument can
      be a pattern including wildcard characters.
      
      Author: Andrew Dunstan.
      Reviewd-by: Fabien Coelho and Michael Paquier
      Discussion: https://postgr.es/m/43a54a47-4aa7-c70e-9ca6-648f436dd6e6@2ndQuadrant.com
      f092de05
    • Amit Kapila's avatar
      Clear the local map when not used. · 9c32e4c3
      Amit Kapila authored
      After commit b0eaa4c5, we use a local map of pages to find the required
      space for small relations.  We do clear this map when we have found a block
      with enough free space, when we extend the relation, or on transaction
      abort so that it can be used next time.  However, we miss to clear it when
      we didn't find any pages to try from the map which leads to an assertion
      failure when we later tried to use it after relation extension.
      
      In the passing, I have improved some comments in this area.
      
      Reported-by: Tom Lane based on buildfarm results
      Author: Amit Kapila
      Reviewed-by: John Naylor
      Tested-by: Kuntal Ghosh
      Discussion: https://postgr.es/m/32368.1551114120@sss.pgh.pa.us
      9c32e4c3
    • Michael Paquier's avatar
      Make pg_partition_tree return no rows on unsupported and undefined objects · 0f3cdf87
      Michael Paquier authored
      The function was tweaked so as it returned one row full of NULLs when
      working on an unsupported relkind or an undefined object as of cc53123b,
      and after discussion with Amit and Álvaro it looks more natural to make
      it return no rows.
      
      Author: Michael Paquier
      Reviewed-by: Álvaro Herrera, Amit Langote
      Discussion: https://postgr.es/m/20190227184808.GA17357@alvherre.pgsql
      0f3cdf87
  2. 28 Feb, 2019 15 commits
  3. 27 Feb, 2019 9 commits
  4. 26 Feb, 2019 6 commits
    • Robert Haas's avatar
      Change lock acquisition order in expand_inherited_rtentry. · f4b6341d
      Robert Haas authored
      Previously, this function acquired locks in the order using
      find_all_inheritors(), which locks the children of each table that it
      processes in ascending OID order, and which processes the inheritance
      hierarchy as a whole in a breadth-first fashion.  Now, it processes
      the inheritance hierarchy in a depth-first fashion, and at each level
      it proceeds in the order in which tables appear in the PartitionDesc.
      If table inheritance rather than table partitioning is used, the old
      order is preserved.
      
      This change moves the locking of any given partition much closer to
      the code that actually expands that partition.  This seems essential
      if we ever want to allow concurrent DDL to add or remove partitions,
      because if the set of partitions can change, we must use the same data
      to decide which partitions to lock as we do to decide which partitions
      to expand; otherwise, we might expand a partition that we haven't
      locked.  It should hopefully also facilitate efforts to postpone
      inheritance expansion or locking for performance reasons, because
      there's really no way to postpone locking some partitions if
      we're blindly locking them all using find_all_inheritors().
      
      The only downside of this change which is known to me is that it
      further deviates from the principle that we should always lock the
      inheritance hierarchy in find_all_inheritors() order to avoid deadlock
      risk.  However, we've already crossed that bridge in commit
      9eefba18 and there are futher patches
      pending that make similar changes, so this isn't really giving up
      anything that we haven't surrendered already -- and it seems entirely
      worth it, given the performance benefits some of those changes seem
      likely to bring.
      
      Patch by me; thanks to David Rowley for discussion of these issues.
      
      Discussion: http://postgr.es/m/CAKJS1f_eEYVEq5tM8sm1k-HOwG0AyCPwX54XG9x4w0zy_N4Q_Q@mail.gmail.com
      Discussion: http://postgr.es/m/CA+TgmoZUwPf_uanjF==gTGBMJrn8uCq52XYvAEorNkLrUdoawg@mail.gmail.com
      f4b6341d
    • Michael Meskes's avatar
      Free memory in ecpg bytea regression test. · 42ccbe43
      Michael Meskes authored
      While not really a problem it's easier to run tools like valgrind against it
      when fixed.
      42ccbe43
    • Michael Meskes's avatar
    • Michael Paquier's avatar
      Simplify some code in pg_rewind when syncing target directory · 6e52209e
      Michael Paquier authored
      9a4059d4 simplified the flush of target data folder when finishing
      processing, and could have done a bit more.
      
      Discussion: https://postgr.es/m/20190131064759.GA13429@paquier.xyz
      6e52209e
    • Peter Geoghegan's avatar
      Remove unneeded argument from _bt_getstackbuf(). · 2ab23445
      Peter Geoghegan authored
      _bt_getstackbuf() is called at exactly two points following commit
      efada2b8 (one call site is concerned with page splits, while the
      other is concerned with page deletion).  The parent buffer returned by
      _bt_getstackbuf() is write-locked in both cases.  Remove the 'access'
      argument and make _bt_getstackbuf() assume that callers require a
      write-lock.
      2ab23445
    • Peter Geoghegan's avatar
      Correct obsolete nbtree page deletion comment. · 067786ce
      Peter Geoghegan authored
      Commit efada2b8, which made the nbtree page deletion algorithm more
      robust, removed _bt_getstackbuf() calls from _bt_pagedel().  It failed
      to update a comment that referenced the earlier approach.  Update the
      comment to explain that the _bt_getstackbuf() page deletion call site
      mirrors the only other remaining _bt_getstackbuf() call site, which is
      reached during page splits.
      067786ce
  5. 25 Feb, 2019 3 commits
    • Peter Eisentraut's avatar
      psql: Remove obsolete code · b6926dee
      Peter Eisentraut authored
      The check in create_help.pl for a null end tag (</>) has been obsolete
      since the conversion from SGML to XML, since XML does not allow that
      anymore.
      b6926dee
    • Peter Eisentraut's avatar
      Remove unnecessary use of PROCEDURAL · bc09d5e4
      Peter Eisentraut authored
      Remove some unnecessary, legacy-looking use of the PROCEDURAL keyword
      before LANGUAGE.  We mostly don't use this anymore, so some of these
      look a bit old.
      
      There is still some use in pg_dump, which is harder to remove because
      it's baked into the archive format, so I'm not touching that.
      
      Discussion: https://www.postgresql.org/message-id/2330919b-62d9-29ac-8de3-58c024fdcb96@2ndquadrant.com
      bc09d5e4
    • Michael Paquier's avatar
      Make release of 2PC identifier and locks consistent in COMMIT PREPARED · effe7d95
      Michael Paquier authored
      When preparing a transaction in two-phase commit, a dummy PGPROC entry
      holding the GID used for the transaction is registered, which gets
      released once COMMIT PREPARED is run.  Prior releasing its shared memory
      state, all the locks taken in the prepared transaction are released
      using a dedicated set of callbacks (pgstat and multixact having similar
      callbacks), which may cause the locks to be released before the GID is
      set free.
      
      Hence, there is a small window where lock conflicts could happen, for
      example:
      - Transaction A releases its locks, still holding its GID in shared
      memory.
      - Transaction B held a lock which conflicted with locks of transaction
      A.
      - Transaction B continues its processing, reusing the same GID as
      transaction A.
      - Transaction B fails because of a conflicting GID, already in use by
      transaction A.
      
      This commit changes the shared memory state release so as post-commit
      callbacks and predicate lock cleanup happen consistently with the shared
      memory state cleanup for the dummy PGPROC entry.  The race window is
      small and 2PC had this issue from the start, so no backpatch is done.
      On top if that fixes discussed involved ABI breakages, which are not
      welcome in stable branches.
      
      Reported-by: Oleksii Kliukin, Ildar Musin
      Diagnosed-by: Oleksii Kliukin, Ildar Musin
      Author: Michael Paquier
      Reviewed-by: Masahiko Sawada, Oleksii Kliukin
      Discussion: https://postgr.es/m/BF9B38A4-2BFF-46E8-BA87-A2D00A8047A6@hintbits.com
      effe7d95
  6. 24 Feb, 2019 2 commits
    • Thomas Munro's avatar
      Fix inconsistent out-of-memory error reporting in dsa.c. · 29ddb548
      Thomas Munro authored
      Commit 16be2fd1 introduced the flag DSA_ALLOC_NO_OOM to control whether
      the DSA allocator would raise an error or return InvalidDsaPointer on
      failure to allocate.  One edge case was not handled correctly: if we
      fail to allocate an internal "span" object for a large allocation, we
      would always return InvalidDsaPointer regardless of the flag; a caller
      not expecting that could then dereference a null pointer.
      
      This is a plausible explanation for a one-off report of a segfault.
      
      Remove a redundant pair of braces so that all three stanzas that handle
      DSA_ALLOC_NO_OOM match in style, for visual consistency.
      
      While fixing inconsistencies, if FreePageManagerGet() can't supply the
      pages that our book-keeping says it should be able to supply, then we
      should always report a FATAL error.  Previously we treated that as a
      regular allocation failure in one code path, but as a FATAL condition
      in another.
      
      Back-patch to 10, where dsa.c landed.
      
      Author: Thomas Munro
      Reported-by: Jakub Glapa
      Discussion: https://postgr.es/m/CAEepm=2oPqXxyWQ-1o60tpOLrwkw=VpgNXqqF1VN2EyO9zKGQw@mail.gmail.com
      29ddb548
    • Tom Lane's avatar
      Fix ecpg bugs caused by missing semicolons in the backend grammar. · 9e138a40
      Tom Lane authored
      The Bison documentation clearly states that a semicolon is required
      after every grammar rule, and our scripts that generate ecpg's
      grammar from the backend's implicitly assumed this is true.  But it
      turns out that only ancient versions of Bison actually enforce that.
      There have been a couple of rules without trailing semicolons in
      gram.y for some time, and as a consequence, ecpg's grammar was faulty
      and produced wrong output for the affected statements.
      
      To fix, add the missing semis, and add some cross-checks to ecpg's
      scripts so that they'll bleat if we mess this up again.
      
      The cases that were broken were:
      * "SET variable = DEFAULT" (but not "SET variable TO DEFAULT"),
        as well as allied syntaxes such as ALTER SYSTEM SET ... DEFAULT.
        These produced syntactically invalid output that the server
        would reject.
      * Multiple type names in DROP TYPE/DOMAIN commands.  Only the
        first type name would be listed in the emitted command.
      
      Per report from Daisuke Higuchi.  Back-patch to all supported versions.
      
      Discussion: https://postgr.es/m/1803D792815FC24D871C00D17AE95905DB51CE@g01jpexmbkw24
      9e138a40