1. 04 Nov, 2016 8 commits
    • Peter Eisentraut's avatar
      pg_test_timing: Add NLS · 59fa9d2d
      Peter Eisentraut authored
      Also straighten out use of time unit abbreviations a bit.
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      59fa9d2d
    • Peter Eisentraut's avatar
      pg_test_fsync: Add NLS · a39255d7
      Peter Eisentraut authored
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      a39255d7
    • Peter Eisentraut's avatar
      632fbe77
    • Peter Eisentraut's avatar
      pageinspect: Fix unaligned struct access in GIN functions · 84ad68d6
      Peter Eisentraut authored
      The raw page data that is passed into the functions will not be aligned
      at 8-byte boundaries.  Casting that to a struct and accessing int64
      fields will result in unaligned access.  On most platforms, you get away
      with it, but it will result on a crash on pickier platforms such as ia64
      and sparc64.
      84ad68d6
    • Robert Haas's avatar
      Add API to check if an existing exclusive lock allows cleanup. · f2e6a2cc
      Robert Haas authored
      LockBufferForCleanup() acquires a cleanup lock unconditionally, and
      ConditionalLockBufferForCleanup() acquires a cleanup lock if it is
      possible to do so without waiting; this patch adds a new API,
      IsBufferCleanupOK(), which tests whether an exclusive lock already
      held happens to be a cleanup lock.  This is possible because a cleanup
      lock simply means an exclusive lock plus the assurance any other pins
      on the buffer are newer than our own pin.  Therefore, just as the
      existing functions decide that the exclusive lock that they've just
      taken is a cleanup lock if they observe the pin count to be 1, this
      new function allows us to observe that the pin count is 1 on a buffer
      we've already locked.
      
      This is useful in situations where a backend definitely wishes to
      modify the buffer and also wishes to perform cleanup operations if
      possible.  The patch to eliminate heavyweight locking by hash indexes
      uses this, and it may have other applications as well.
      
      Amit Kapila, per a suggestion from me.  Some comment adjustments by me
      as well.
      f2e6a2cc
    • Robert Haas's avatar
      postgres_fdw: Fix typo in comment. · 7016e4c4
      Robert Haas authored
      Etsuro Fujita
      7016e4c4
    • Peter Eisentraut's avatar
      doc: Add index letter links to XSLT HTML build · 97f16b87
      Peter Eisentraut authored
      This matches what was already implemented in the DSSSL HTML build.
      97f16b87
    • Tom Lane's avatar
      Sync our copy of the timezone library with IANA tzcode master. · 1f87181e
      Tom Lane authored
      This patch absorbs some unreleased fixes for symlink manipulation bugs
      introduced in tzcode 2016g.  Ordinarily I'd wait around for a released
      version, but in this case it seems like we could do with extra testing,
      in particular checking whether it works in EDB's VMware build environment.
      This corresponds to commit aec59156abbf8472ba201b6c7ca2592f9c10e077 in
      https://github.com/eggert/tz.
      
      Per a report from Sandeep Thakkar, building in an environment where hard
      links are not supported in the timezone data installation directory failed,
      because upstream code refactoring had broken the case of symlinking from an
      existing symlink.  Further experimentation also showed that the symlinks
      were sometimes made incorrectly, with too many or too few "../"'s in the
      symlink contents.
      
      This should get back-patched, but first let's see what the buildfarm
      makes of it.  I'm not too sure about the new dependency on linkat(2).
      
      Report: <CANFyU94_p6mqRQc2i26PFp5QAOQGB++AjGX=FO8LDpXw0GSTjw@mail.gmail.com>
      Discussion: http://mm.icann.org/pipermail/tz/2016-November/024431.html
      1f87181e
  2. 03 Nov, 2016 4 commits
  3. 02 Nov, 2016 5 commits
    • Tom Lane's avatar
      Don't make FK-based selectivity estimates in inheritance situations. · 77067106
      Tom Lane authored
      The foreign-key-aware logic for estimation of join sizes (added in commit
      100340e2) blindly tried to apply the concept to rels that are actually
      parents of inheritance trees.  This is just plain wrong so far as the
      referenced relation is concerned, since the inheritance scan may well
      produce lots of rows that are not participating in the constraint.  It's
      wrong for the referencing relation too, for the same reason; although on
      that end we could conceivably detect whether all members of the inheritance
      tree have equivalent FK constraints pointing to the same referenced rel,
      and then proceed more or less as we do now.  But pending somebody writing
      code to do that, we must disable this, because it's producing completely
      silly estimates when there's an FK linking the heads of inheritance trees.
      
      Per bug #14404 from Clinton Adams.  Back-patch to 9.6 where the new
      estimation logic came in.
      
      Report: <20161028200412.15987.96482@wrigleys.postgresql.org>
      77067106
    • Tom Lane's avatar
      Don't convert Consts into Vars during setrefs.c processing. · da8f3ebf
      Tom Lane authored
      While converting expressions in an upper-level plan node so that they
      reference Vars and expressions provided by the input plan node(s),
      don't convert plain Const items, even if there happens to be a matching
      Const in the input.  It's silly to do so because a Var is more expensive to
      execute than a Const.  Moreover, converting can fool ExecCheckPlanOutput's
      check that an insert or update query inserts nulls into dropped columns,
      leading to "query provides a value for a dropped column" errors during
      INSERT or UPDATE on a table with a dropped column.  We could solve this
      by making that check more complicated, but I don't see the point; this fix
      should save a marginal number of cycles, and it also makes for less messy
      EXPLAIN output, as shown by the ensuing regression test result changes.
      
      Per report from Pavel Hanák.  I have not incorporated a test case based
      on that example, as there doesn't seem to be a simple way of checking
      this in isolation without making a bunch of assumptions about other
      planner and SQL-function behavior.
      
      Back-patch to 9.6.  This setrefs.c behavior exists much further back,
      but there is not currently reason to think that it causes problems
      before 9.6.
      
      Discussion: <83shraampf.fsf@is-it.eu>
      da8f3ebf
    • Peter Eisentraut's avatar
      pageinspect: Make page test more portable · 00a86856
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness.
      00a86856
    • Tom Lane's avatar
      Fix portability bug in gin_page_opaque_info(). · 14ee3579
      Tom Lane authored
      Somebody apparently thought that "if Int32GetDatum is good,
      Int64GetDatum must be better".  Per buildfarm failures now
      that Peter has added some regression tests here.
      14ee3579
    • Peter Eisentraut's avatar
      pageinspect: Make btree test more portable · f7c9a6e0
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness and
      alignment.
      f7c9a6e0
  4. 01 Nov, 2016 4 commits
  5. 31 Oct, 2016 1 commit
  6. 30 Oct, 2016 5 commits
    • Tatsuo Ishii's avatar
      Fix typo in sources.sgml. · 36d154ec
      Tatsuo Ishii authored
      Per Shinichi Matsuda.
      36d154ec
    • Tom Lane's avatar
      Fix nasty performance problem in tsquery_rewrite(). · 5ec81ace
      Tom Lane authored
      tsquery_rewrite() tries to find matches to subsets of AND/OR conditions;
      for example, in the query 'a | b | c' the substitution subquery 'a | c'
      should match and lead to replacement of the first and third items.
      That's fine, but the matching algorithm apparently takes about O(2^N)
      for an N-clause query (I say "apparently" because the code is also both
      unintelligible and uncommented).  We could probably do better than that
      even without any extra assumptions --- but actually, we know that the
      subclauses are sorted, indeed are depending on that elsewhere in this very
      same function.  So we can just scan the two lists a single time to detect
      matches, as though we were doing a merge join.
      
      Also do a re-flattening call (QTNTernary()) in tsquery_rewrite_query, just
      to make sure that the tree fits the expectations of the next search cycle.
      I didn't try to devise a test case for this, but I'm pretty sure that the
      oversight could have led to failure to match in some cases where a match
      would be expected.
      
      Improve comments, and also stick a CHECK_FOR_INTERRUPTS into
      dofindsubquery, just in case it's still too slow for somebody.
      
      Per report from Andreas Seltenreich.  Back-patch to all supported branches.
      
      Discussion: <8760oasf2y.fsf@credativ.de>
      5ec81ace
    • Tom Lane's avatar
      Fix bogus tree-flattening logic in QTNTernary(). · 24ebc444
      Tom Lane authored
      QTNTernary() contains logic to flatten, eg, '(a & b) & c' into 'a & b & c',
      which is all well and good, but it tries to do that to NOT nodes as well,
      so that '!!a' gets changed to '!a'.  Explicitly restrict the conversion to
      be done only on AND and OR nodes, and add a test case illustrating the bug.
      
      In passing, provide some comments for the sadly naked functions in
      tsquery_util.c, and simplify some baroque logic in QTNFree(), which
      I think may have been leaking some items it intended to free.
      
      Noted while investigating a complaint from Andreas Seltenreich.
      Back-patch to all supported versions.
      24ebc444
    • Tom Lane's avatar
      Improve speed of aggregates that use array_append as transition function. · 9a00f03e
      Tom Lane authored
      In the previous coding, if an aggregate's transition function returned an
      expanded array, nodeAgg.c and nodeWindowAgg.c would always copy it and thus
      force it into the flat representation.  This led to ping-ponging between
      flat and expanded formats, which costs a lot.  For an aggregate using
      array_append as transition function, I measured about a 15X slowdown
      compared to the pre-9.5 code, when working on simple int[] arrays.
      Of course, the old code was already O(N^2) in this usage due to copying
      flat arrays all the time, but it wasn't quite this inefficient.
      
      To fix, teach nodeAgg.c and nodeWindowAgg.c to allow expanded transition
      values without copying, so long as the transition function takes care to
      return the transition value already properly parented under the aggcontext.
      That puts a bit of extra responsibility on the transition function, but
      doing it this way allows us to not need any extra logic in the fast path
      of advance_transition_function (ie, with a pass-by-value transition value,
      or with a modified-in-place pass-by-reference value).  We already know
      that that's a hot spot so I'm loath to add any cycles at all there.  Also,
      while only array_append currently knows how to follow this convention,
      this solution allows other transition functions to opt-in without needing
      to have a whitelist in the core aggregation code.
      
      (The reason we would need a whitelist is that currently, if you pass a
      R/W expanded-object pointer to an arbitrary function, it's allowed to do
      anything with it including deleting it; that breaks the core agg code's
      assumption that it should free discarded values.  Returning a value under
      aggcontext is the transition function's signal that it knows it is an
      aggregate transition function and will play nice.  Possibly the API rules
      for expanded objects should be refined, but that would not be a
      back-patchable change.)
      
      With this fix, an aggregate using array_append is no longer O(N^2), so it's
      much faster than pre-9.5 code rather than much slower.  It's still a bit
      slower than the bespoke infrastructure for array_agg, but the differential
      seems to be only about 10%-20% rather than orders of magnitude.
      
      Discussion: <6315.1477677885@sss.pgh.pa.us>
      9a00f03e
    • Magnus Hagander's avatar
      Fix memory leak in tar file padding · a775406e
      Magnus Hagander authored
      Spotted by Coverity, patch by Michael Paquier
      a775406e
  7. 28 Oct, 2016 3 commits
    • Robert Haas's avatar
      pgstattuple: Don't take heavyweight locks when examining a hash index. · d4b5d4ca
      Robert Haas authored
      It's currently necessary to take a heavyweight lock when scanning a
      hash bucket, but pgstattuple only examines individual pages, so it
      doesn't need to do this.  If, for some hypothetical reason, it did
      need to do any heavyweight locking here, this logic would probably
      still be incorrect, because most of the locks that it is taking are
      meaningless.  Only a heavyweight lock on a primary bucket page has any
      meaning, but this takes heavyweight locks on all pages regardless of
      function - and in particular overflow pages, where you might imagine
      that we'd want to lock the primary bucket page if we needed to lock
      anything at all.
      
      This is arguably a bug that has existed since this code was added in
      commit dab42382, but I'm not going to
      bother back-patching it because in most cases the only consequence is
      that running pgstattuple() on a hash index is a little slower than it
      otherwise might be, which is no big deal.
      
      Extracted from a vastly larger patch by Amit Kapila which heavyweight
      locking for hash indexes entirely; analysis of why this can be done
      independently of the rest by me.
      d4b5d4ca
    • Robert Haas's avatar
      Fix leftover reference to background writer performing checkpoints. · 33839b5f
      Robert Haas authored
      This was changed in PostgreSQL 9.2, but somehow this comment never
      got updated.
      33839b5f
    • Peter Eisentraut's avatar
      doc: Small style improvements · a94b7035
      Peter Eisentraut authored
      a94b7035
  8. 27 Oct, 2016 7 commits
    • Peter Eisentraut's avatar
      Remove invitation to report a bug about unknown encoding · ce4dc970
      Peter Eisentraut authored
      The error message when we couldn't determine the encoding from a locale
      said to report a bug about that.  That might have been appropriate when
      this code was first added, but by now this works pretty solidly and any
      encodings we don't recognize we probably just don't support.  We still
      print the warning, but no longer invite the bug report.
      ce4dc970
    • Peter Eisentraut's avatar
      Add function name to PyArg_ParseTuple() · eaed88ce
      Peter Eisentraut authored
      This causes the supplied function name to appear in any error message,
      making the error message friendlier and relieving us from having to
      provide our own in some cases.
      eaed88ce
    • Peter Eisentraut's avatar
      Format PL/Python module contents test vertically · 84d457ed
      Peter Eisentraut authored
      It makes it readable again and makes merges more manageable.
      84d457ed
    • Robert Haas's avatar
      If the stats collector dies during Hot Standby, restart it. · 4f714b2f
      Robert Haas authored
      This bug exists as far back as 9.0, when Hot Standby was introduced,
      so back-patch to all supported branches.
      
      Report and patch by Takayuki Tsunakawa, reviewed by Michael Paquier
      and Kuntal Ghosh.
      4f714b2f
    • Robert Haas's avatar
      Fix possible pg_basebackup failure on standby with "include WAL". · f267c1c2
      Robert Haas authored
      If a restartpoint flushed no dirty buffers, it could fail to update
      the minimum recovery point, leading to a minimum recovery point prior
      to the starting REDO location.  perform_base_backup() would interpret
      that as meaning that no WAL files at all needed to be included in the
      backup, failing an internal sanity check.  To fix, have restartpoints
      always update the minimum recovery point to just after the checkpoint
      record itself, so that the file (or files) containing the checkpoint
      record will always be included in the backup.
      
      Code by Amit Kapila, per a design suggestion by me, with some
      additional work on the code comment by me.  Test case by Michael
      Paquier.  Report by Kyotaro Horiguchi.
      f267c1c2
    • Peter Eisentraut's avatar
      Avoid using a C++ keyword in header file · c32fe432
      Peter Eisentraut authored
      per cpluspluscheck
      c32fe432
    • Bruce Momjian's avatar
      Properly indent postgresql.conf comments to align · 586a46c2
      Bruce Momjian authored
      A few comments were misaligned.
      586a46c2
  9. 26 Oct, 2016 3 commits
    • Tom Lane's avatar
      Fix incorrect trigger-property updating in ALTER CONSTRAINT. · a522fc3d
      Tom Lane authored
      The code to change the deferrability properties of a foreign-key constraint
      updated all the associated triggers to match; but a moment's examination of
      the code that creates those triggers in the first place shows that only
      some of them should track the constraint's deferrability properties.  This
      leads to odd failures in subsequent exercise of the foreign key, as the
      triggers are fired at the wrong times.  Fix that, and add a regression test
      comparing the trigger properties produced by ALTER CONSTRAINT with those
      you get by creating the constraint as-intended to begin with.
      
      Per report from James Parks.  Back-patch to 9.4 where this ALTER
      functionality was introduced.
      
      Report: <CAJ3Xv+jzJ8iNNUcp4RKW8b6Qp1xVAxHwSXVpjBNygjKxcVuE9w@mail.gmail.com>
      a522fc3d
    • Tom Lane's avatar
      Fix not-HAVE_SYMLINK code in zic.c. · 19b2094d
      Tom Lane authored
      I broke this in commit f3094920.  Apparently it's dead code anyway,
      at least as far as our buildfarm is concerned (and the upstream IANA
      code doesn't worry at all about symlink() not being present).
      But as long as the rest of our code is willing to guard against not
      having symlink(), this should too.  Noted while investigating a
      tangentially-related complaint from Sandeep Thakkar.
      
      Back-patch to keep branches in sync.
      19b2094d
    • Tom Lane's avatar
      Doc: improve documentation about inheritance. · 162477a6
      Tom Lane authored
      Clarify documentation about inheritance of check constraints, in
      particular mentioning the NO INHERIT option, which didn't exist when
      this text was written.
      
      Document that in an inherited query, the applicable row security policies
      are those of the explicitly-named table, not its children.  This is the
      intended behavior (per off-list discussion with Stephen Frost), and there
      are regression tests for it, but it wasn't documented anywhere user-facing
      as far as I could find.
      
      Do a bit of wordsmithing on the description of inherited access-privilege
      checks.
      
      Back-patch to 9.5 where RLS was added.
      162477a6