1. 06 Feb, 2019 7 commits
    • Peter Geoghegan's avatar
      Avoid amcheck inline compression false positives. · eba77534
      Peter Geoghegan authored
      The previous tacit assumption that index_form_tuple() hides differences
      in the TOAST state of its input datums was wrong.  Normalize input
      varlena datums by decompressing compressed values, and forming a new
      index tuple for fingerprinting using uncompressed inputs.  The final
      normalized representation may actually be compressed once again within
      index_form_tuple(), though that shouldn't matter.  When the original
      tuple is found to have no datums that are compressed inline, fingerprint
      the original tuple directly.
      
      Normalization avoids false positive reports of corruption in certain
      cases.  For example, the executor can apply toasting with some inline
      compression to an entire heap tuple because its input has a single
      external TOAST pointer.  Varlena datums for other attributes that are
      not particularly good candidates for inline compression can be
      compressed in the heap tuple in passing, without the representation of
      the same values in index tuples ever receiving concomitant inline
      compression.
      
      Add a test case to recreate the issue in a simpler though less realistic
      way: by exploiting differences in pg_attribute.attstorage between heap
      and index relations.
      
      This bug was discovered by me during testing of an upcoming set of nbtree
      enhancements.  It was also independently reported by Andreas Kunert, as
      bug #15597.  His test case was rather more realistic than the one I
      ended up using.
      
      Bug: #15597
      Discussion: https://postgr.es/m/CAH2-WznrVd9ie+TTJ45nDT+v2nUt6YJwQrT9SebCdQKtAvfPZw@mail.gmail.com
      Discussion: https://postgr.es/m/15597-294e5d3e7f01c407@postgresql.org
      Backpatch: 11-, where heapallindexed verification was introduced.
      eba77534
    • Peter Eisentraut's avatar
      Hide cascade messages in collate tests · 727921f4
      Peter Eisentraut authored
      These are not relevant to the tests and would just uselessly bloat
      patches.
      727921f4
    • Tom Lane's avatar
      Propagate lateral-reference information to indirect descendant relations. · bdd9a99a
      Tom Lane authored
      create_lateral_join_info() computes a bunch of information about lateral
      references between base relations, and then attempts to propagate those
      markings to appendrel children of the original base relations.  But the
      original coding neglected the possibility of indirect descendants
      (grandchildren etc).  During v11 development we noticed that this was
      wrong for partitioned-table cases, but failed to realize that it was just
      as wrong for any appendrel.  While the case can't arise for appendrels
      derived from traditional table inheritance (because we make a flat
      appendrel for that), nested appendrels can arise from nested UNION ALL
      subqueries.  Failure to mark the lower-level relations as having lateral
      references leads to confusion in add_paths_to_append_rel about whether
      unparameterized paths can be built.  It's not very clear whether that
      leads to any user-visible misbehavior; the lack of field reports suggests
      that it may cause nothing worse than minor cost misestimation.  Still,
      it's a bug, and it leads to failures of Asserts that I intend to add
      later.
      
      To fix, we need to propagate information from all appendrel parents,
      not just those that are RELOPT_BASERELs.  We can still do it in one
      pass, if we rely on the append_rel_list to be ordered with ancestor
      relationships before descendant ones; add assertions checking that.
      While fixing this, we can make a small performance improvement by
      traversing the append_rel_list just once instead of separately for
      each appendrel parent relation.
      
      Noted while investigating bug #15613, though this patch does not fix
      that (which is why I'm not committing the related Asserts yet).
      
      Discussion: https://postgr.es/m/3951.1549403812@sss.pgh.pa.us
      bdd9a99a
    • Andrew Dunstan's avatar
      Unify searchpath and do file logic in MSVC build scripts. · 592123ef
      Andrew Dunstan authored
      Commit f83419b7 failed to notice that mkvcbuild.pl and build.pl use
      different searchpath and do-file logic, breaking the latter, so it is
      adjusted to use the same logic as mkvcbuild.pl.
      592123ef
    • Andres Freund's avatar
      Fix heap_getattr() handling of fast defaults. · 171e0418
      Andres Freund authored
      Previously heap_getattr() returned NULL for attributes with a fast
      default value (c.f. 16828d5c), as it had no handling whatsoever
      for that case.
      
      A previous fix, 7636e5c6, attempted to fix issues caused by this
      oversight, but just expanding OLD tuples for triggers doesn't actually
      solve the underlying issue.
      
      One known consequence of this bug is that the check for HOT updates
      can return the wrong result, when a previously fast-default'ed column
      is set to NULL. Which in turn means that an index over a column with
      fast default'ed columns might be corrupt if the underlying column(s)
      allow NULLs.
      
      Fix by handling fast default columns in heap_getattr(), remove now
      superfluous expansion in GetTupleForTrigger().
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20190201162404.onngi77f26baem4g@alap3.anarazel.de
      Backpatch: 11, where fast defaults were introduced
      171e0418
    • Michael Paquier's avatar
      Tighten some regexes with proper character escaping in pg_dump TAP tests · d07fb681
      Michael Paquier authored
      Some tests have been using regular expressions which have been lax in
      escaping dots, which may cause tests to pass when they should not.  This
      make the whole set of tests more robust where needed.
      
      Author: David Rowley
      Reviewed-by: Daniel Gustafsson, Michael Paquier
      Discussion: https://postgr.es/m/CAKJS1f9jD8aVo1BTH+Vgwd=f-ynbuRVrS90XbWMT6UigaOQJTA@mail.gmail.com
      d07fb681
    • Andrew Dunstan's avatar
      Fix included file path for modern perl · f83419b7
      Andrew Dunstan authored
      Contrary to the comment on 772d4b76, only paths starting with "./" or
      "../" are considered relative to the current working directory by perl's
      "do" function. So this patch converts all the relevant cases to use "./"
      paths. This only affects MSVC.
      
      Backpatch to all live branches.
      f83419b7
  2. 05 Feb, 2019 5 commits
    • Andrew Dunstan's avatar
      Keep perl style checker happy · 8916b33e
      Andrew Dunstan authored
      It doesn't like code before "use strict;".
      8916b33e
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2018i. · d63dc0aa
      Tom Lane authored
      DST law changes in Kazakhstan, Metlakatla, and São Tomé and Príncipe.
      Kazakhstan's Qyzylorda zone is split in two, creating a new zone
      Asia/Qostanay, as some areas did not change UTC offset.
      Historical corrections for Hong Kong and numerous Pacific islands.
      d63dc0aa
    • Andrew Dunstan's avatar
      Fix searchpath for modern Perl for genbki.pl · f884a968
      Andrew Dunstan authored
      This was fixed for MSVC tools by commit 1df92eea, but per
      buildfarm member bowerbird genbki.pl needs the same treatment.
      
      Backpatch to all live branches.
      f884a968
    • Tom Lane's avatar
      Remove unnecessary "inline" marker introduced in commit 4be058fe. · 24114e8b
      Tom Lane authored
      Some of our older buildfarm members bleat about this coding,
      along the lines of
      
      prepjointree.c:112: warning: 'get_result_relid' declared inline after being called
      prepjointree.c:112: warning: previous declaration of 'get_result_relid' was here
      
      Modern compilers will probably inline this function without being
      prompted, so rather than move the function, let's just drop the
      marking.
      24114e8b
    • Tom Lane's avatar
      Doc: in each release branch, keep only that branch's own release notes. · 527b5ed1
      Tom Lane authored
      Historically we've had each release branch include all prior branches'
      notes, including minor-release changes, back to the beginning of the
      project.  That's basically an O(N^2) proposition, and it was starting to
      catch up with us: as of HEAD the back-branch release notes alone accounted
      for nearly 30% of the documentation.  While there's certainly some value
      in easy access to back-branch notes, this is getting out of hand.
      
      Hence, switch over to the rule that each branch contains only its own
      release notes.  So as to not make older notes too hard to find, each
      branch will provide URLs for the immediately preceding branches'
      release notes on the project website.
      
      There might be value in providing aggregated notes across all branches
      somewhere on the website, but that's a task for another day.
      
      Discussion: https://postgr.es/m/cbd4aeb5-2d9c-8b84-e968-9e09393d4c83@postgresql.org
      527b5ed1
  3. 04 Feb, 2019 6 commits
    • Tom Lane's avatar
      Fix dumping of matviews with indirect dependencies on primary keys. · 6e4d45b5
      Tom Lane authored
      Commit 62215de2 turns out to have been not quite on-the-mark.
      When we are forced to postpone dumping of a materialized view into
      the dump's post-data section (because it depends on a unique index
      that isn't created till that section), we may also have to postpone
      dumping other matviews that depend on said matview.  The previous fix
      didn't reliably work for such cases: it'd break the dependency loops
      properly, producing a workable object ordering, but it didn't
      necessarily mark all the matviews as "postponed_def".  This led to
      harmless bleating about "archive items not in correct section order",
      as reported by Tom Cassidy in bug #15602.  Less harmlessly,
      selective-restore options such as --section might misbehave due to
      the matview dump objects not being properly labeled.
      
      The right way to fix it is to consider that each pre-data dependency
      we break amounts to moving the no-longer-dependent object into
      post-data, and hence we should mark that object if it's a matview.
      
      Back-patch to all supported versions, since the issue's been there
      since matviews were introduced.
      
      Discussion: https://postgr.es/m/15602-e895445f73dc450b@postgresql.org
      6e4d45b5
    • Peter Eisentraut's avatar
      Remove unused macro · f602cf49
      Peter Eisentraut authored
      Use was removed in 6d46f478 but
      definition was forgotten.
      f602cf49
    • Andrew Gierth's avatar
      Move port-specific parts of with_temp_install to port makefile. · 54f5f887
      Andrew Gierth authored
      Rather than define ld_library_path_ver with a big nested $(if), just
      put the overriding values in the makefiles for the relevant ports.
      
      Also add a variable for port makefiles to append their own stuff to
      with_temp_install, and use it to set LD_LIBRARY_PATH_RPATH=1 on
      FreeBSD which is needed to make LD_LIBRARY_PATH override DT_RPATH
      if DT_RUNPATH is not set (which seems to depend in unpredictable ways
      on the choice of compiler, at least on my system).
      
      Backpatch for the benefit of anyone doing regression tests on FreeBSD.
      (For other platforms there should be no functional change.)
      54f5f887
    • Amit Kapila's avatar
      Make FSM test portable. · 08ecdfe7
      Amit Kapila authored
      In b0eaa4c5, we allow FSM to be created only after 4 pages.  One of the
      tests check the FSM contents and to do that it populates many tuples in
      the relation.  The FSM contents depend on the availability of freespace in
      the page and it could vary because of the alignment of tuples.
      
      This commit removes the dependency on FSM contents.
      
      Author: Amit Kapila
      Discussion: https://postgr.es/m/CAA4eK1KADF6K1bagr0--mGv3dMcZ%3DH_Z-Qtvdfbp5PjaC6PJJA%40mail.gmail.com
      08ecdfe7
    • Amit Kapila's avatar
      Avoid creation of the free space map for small heap relations, take 2. · b0eaa4c5
      Amit Kapila authored
      Previously, all heaps had FSMs. For very small tables, this means that the
      FSM took up more space than the heap did. This is wasteful, so now we
      refrain from creating the FSM for heaps with 4 pages or fewer. If the last
      known target block has insufficient space, we still try to insert into some
      other page before giving up and extending the relation, since doing
      otherwise leads to table bloat. Testing showed that trying every page
      penalized performance slightly, so we compromise and try every other page.
      This way, we visit at most two pages. Any pages with wasted free space
      become visible at next relation extension, so we still control table bloat.
      As a bonus, directly attempting one or two pages can even be faster than
      consulting the FSM would have been.
      
      Once the FSM is created for a heap we don't remove it even if somebody
      deletes all the rows from the corresponding relation.  We don't think it is
      a useful optimization as it is quite likely that relation will again grow
      to the same size.
      
      Author: John Naylor, Amit Kapila
      Reviewed-by: Amit Kapila
      Tested-by: Mithun C Y
      Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail.com
      b0eaa4c5
    • Michael Paquier's avatar
      Clarify behavior of initdb's --allow-group-access on Windows in docs · be12aa47
      Michael Paquier authored
      The option is ignored on Windows, and GUC data_directory_mode already
      mentioned that within its description in the documentation.
      
      Author: Michael Paquier
      Reported-by: Haribabu Kommi, David Steele
      Discussion: https://postgr.es/m/CAJrrPGefxTG43yk6BrOC7ZcMnCTccG9+inCSncvyys_t8Ev9cQ@mail.gmail.com
      Backpatch-through: 11
      be12aa47
  4. 03 Feb, 2019 3 commits
    • Thomas Munro's avatar
      Add shared_memory_type GUC. · f1bebef6
      Thomas Munro authored
      Since 9.3 we have used anonymous shared mmap for our main shared memory
      region, except in EXEC_BACKEND builds.  Provide a GUC so that users
      can opt for System V shared memory once again, like in 9.2 and earlier.
      
      A later patch proposes to add huge/large page support for AIX, which
      requires System V shared memory and provided the motivation to revive
      this possibility.  It may also be useful on some BSDs.
      
      Author: Andres Freund (revived and documented by Thomas Munro)
      Discussion: https://postgr.es/m/HE1PR0202MB28126DB4E0B6621CC6A1A91286D90%40HE1PR0202MB2812.eurprd02.prod.outlook.com
      Discussion: https://postgr.es/m/2AE143D2-87D3-4AD1-AC78-CE2258230C05%40FreeBSD.org
      f1bebef6
    • Andres Freund's avatar
      Move page initialization from RelationAddExtraBlocks() to use, take 2. · 0d1fe9f7
      Andres Freund authored
      Previously we initialized pages when bulk extending in
      RelationAddExtraBlocks(). That has a major disadvantage: It ties
      RelationAddExtraBlocks() to heap, as other types of storage are likely
      to need different amounts of special space, have different amount of
      free space (previously determined by PageGetHeapFreeSpace()).
      
      That we're relying on initializing pages, but not WAL logging the
      initialization, also means the risk for getting
      "WARNING:  relation \"%s\" page %u is uninitialized --- fixing"
      style warnings in vacuums after crashes/immediate shutdowns, is
      considerably higher. The warning sounds much more serious than what
      they are.
      
      Fix those two issues together by not initializing pages in
      RelationAddExtraPages() (but continue to do so in
      RelationGetBufferForTuple(), which is linked much more closely to
      heap), and accepting uninitialized pages as normal in
      vacuumlazy.c. When vacuumlazy encounters an empty page it now adds it
      to the FSM, but does nothing else.  We chose to not issue a debug
      message, much less a warning in that case - it seems rarely useful,
      and quite likely to scare people unnecessarily.
      
      For now empty pages aren't added to the VM, because standbys would not
      re-discover such pages after a promotion. In contrast to other sources
      for empty pages, there's no corresponding WAL records triggering FSM
      updates during replay.
      
      Previously when extending the relation, there was a moment between
      extending the relation, and acquiring an exclusive lock on the new
      page, in which another backend could lock the page. To avoid new
      content being put on that new page, vacuumlazy needed to acquire the
      extension lock for a brief moment when encountering a new page. A
      second corner case, only working somewhat by accident, was that
      RelationGetBufferForTuple() sometimes checks the last page in a
      relation for free space, without consulting the FSM; that only worked
      because PageGetHeapFreeSpace() interprets the zero page header in a
      new page as no free space.  The lack of handling this properly
      required reverting the previous attempt in 68420054.
      
      This issue can be solved by using RBM_ZERO_AND_LOCK when extending the
      relation, thereby avoiding this window. There's some added complexity
      when RelationGetBufferForTuple() is called with another buffer (for
      updates), to avoid deadlocks, but that's rarely hit at runtime.
      
      Author: Andres Freund
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/20181219083945.6khtgm36mivonhva@alap3.anarazel.de
      0d1fe9f7
    • Michael Paquier's avatar
      Add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to PGXS · ac3a9afd
      Michael Paquier authored
      Add PG_CFLAGS, PG_CXXFLAGS, and PG_LDFLAGS variables to pgxs.mk which
      will be appended or prepended to the corresponding make variables.
      Notably, there was previously no way to pass custom CXXFLAGS to third
      party extension module builds, COPT and PROFILE supporting only CFLAGS
      and LDFLAGS.
      
      Backpatch all the way down to ease integration with existing
      extensions.
      
      Author: Christoph Berg
      Reviewed-by: Andres Freund, Tom Lane, Michael Paquier
      Discussion: https://postgr.es/m/20181113104005.GA32154@msg.credativ.de
      Backpatch-through: 9.4
      ac3a9afd
  5. 02 Feb, 2019 2 commits
    • Amit Kapila's avatar
      Avoid possible deadlock while locking multiple heap pages. · 0b8bdb3c
      Amit Kapila authored
      To avoid deadlock, backend acquires a lock on heap pages in block
      number order.  In certain cases, lock on heap pages is dropped and
      reacquired.  In this case, the locks are dropped for reading in
      corresponding VM page/s. The issue is we re-acquire locks in bufferId
      order whereas the intention was to acquire in blockid order.
      
      This commit ensures that we will always acquire locks on heap pages in
      blockid order.
      
      Reported-by: Nishant Fnu
      Author: Nishant Fnu
      Reviewed-by: Amit Kapila and Robert Haas
      Backpatch-through: 9.4
      Discussion: https://postgr.es/m/5883C831-2ED1-47C8-BFAC-2D5BAE5A8CAE@amazon.com
      0b8bdb3c
    • Michael Paquier's avatar
      Improve installation instructions with pg_ctl in documentation · 3e938a83
      Michael Paquier authored
      The documentation includes sections to be able to initialize and start
      Postgres via a couple of commands.  Some of its recommendations involve
      using directly "postgres", which is inconsistent with the recommendation
      given by initdb.  At the same time make some other command calls more
      consistent with the rest, by using an absolute path when creating a
      database.
      
      Author: Andreas Scherbaum
      Reviewed-by: Michael Banck, Ryan Lambert
      3e938a83
  6. 01 Feb, 2019 6 commits
  7. 31 Jan, 2019 3 commits
  8. 30 Jan, 2019 7 commits
  9. 29 Jan, 2019 1 commit
    • Tom Lane's avatar
      Rename nodes/relation.h to nodes/pathnodes.h. · fa2cf164
      Tom Lane authored
      The old name of this file was never a very good indication of what it
      was for.  Now that there's also access/relation.h, we have a potential
      confusion hazard as well, so let's rename it to something more apropos.
      Per discussion, "pathnodes.h" is reasonable, since a good fraction of
      the file is Path node definitions.
      
      While at it, tweak a couple of other headers that were gratuitously
      importing relation.h into modules that don't need it.
      
      Discussion: https://postgr.es/m/7719.1548688728@sss.pgh.pa.us
      fa2cf164