1. 07 Aug, 2015 5 commits
    • Andres Freund's avatar
      Address points made in post-commit review of replication origins. · 18e86135
      Andres Freund authored
      Amit reviewed the replication origins patch and made some good
      points. Address them. This fixes typos in error messages, docs and
      comments and adds a missing error check (although in a
      should-never-happen scenario).
      
      Discussion: CAA4eK1JqUBVeWWKwUmBPryFaje4190ug0y-OAUHWQ6tD83V4xg@mail.gmail.com
      Backpatch: 9.5, where replication origins were introduced.
      18e86135
    • Bruce Momjian's avatar
      9.5 release notes: updates from Andres Freund and Jeff Janes · d6a8c943
      Bruce Momjian authored
      Report by Andres Freund and Jeff Janes
      
      Backpatch through 9.5
      d6a8c943
    • Tom Lane's avatar
      Fix old oversight in join removal logic. · bab163e1
      Tom Lane authored
      Commit 9e7e29c7 introduced an Assert that
      join removal didn't reduce the eval_at set of any PlaceHolderVar to empty.
      At first glance it looks like join_is_removable ensures that's true --- but
      actually, the loop in join_is_removable skips PlaceHolderVars that are not
      referenced above the join due to be removed.  So, if we don't want any
      empty eval_at sets, the right thing to do is to delete any now-unreferenced
      PlaceHolderVars from the data structure entirely.
      
      Per fuzz testing by Andreas Seltenreich.  Back-patch to 9.3 where the
      aforesaid Assert was added.
      bab163e1
    • Bruce Momjian's avatar
      9.5 release notes: mention ON CONFLICT DO NOTHING for FDWs · 58e09b90
      Bruce Momjian authored
      Report by Peter Geoghegan
      
      Backpatch through 9.5
      58e09b90
    • Tom Lane's avatar
      Fix eclass_useful_for_merging to give valid results for appendrel children. · cde35cf4
      Tom Lane authored
      Formerly, this function would always return "true" for an appendrel child
      relation, because it would think that the appendrel parent was a potential
      join target for the child.  In principle that should only lead to some
      inefficiency in planning, but fuzz testing by Andreas Seltenreich disclosed
      that it could lead to "could not find pathkey item to sort" planner errors
      in odd corner cases.  Specifically, we would think that all columns of a
      child table's multicolumn index were interesting pathkeys, causing us to
      generate a MergeAppend path that sorts by all the columns.  However, if any
      of those columns weren't actually used above the level of the appendrel,
      they would not get added to that rel's targetlist, which would result in
      being unable to resolve the MergeAppend's sort keys against its targetlist
      during createplan.c.
      
      Backpatch to 9.3.  In older versions, columns of an appendrel get added
      to its targetlist even if they're not mentioned above the scan level,
      so that the failure doesn't occur.  It might be worth back-patching this
      fix to older versions anyway, but I'll refrain for the moment.
      cde35cf4
  2. 06 Aug, 2015 11 commits
    • Bruce Momjian's avatar
      9.5 release notes: mention change to CRC-32C · c9351f03
      Bruce Momjian authored
      Report by Andres Freund
      
      Backpatch through 9.5
      c9351f03
    • Bruce Momjian's avatar
      9.5 release notes: adjustments suggested by Andres Freund · c4318c40
      Bruce Momjian authored
      Report by Andres Freund
      
      Backpatch through 9.5
      c4318c40
    • Bruce Momjian's avatar
      9.5 release notes: add non-LEAKPROOF view pushdown mention · 68b5163b
      Bruce Momjian authored
      Report by Dean Rasheed
      
      Backpatch through 9.5
      68b5163b
    • Tom Lane's avatar
      Further fixes for degenerate outer join clauses. · 8703059c
      Tom Lane authored
      Further testing revealed that commit f69b4b94 was still a few
      bricks shy of a load: minor tweaking of the previous test cases resulted
      in the same wrong-outer-join-order problem coming back.  After study
      I concluded that my previous changes in make_outerjoininfo() were just
      accidentally masking the problem, and should be reverted in favor of
      forcing syntactic join order whenever an upper outer join's predicate
      doesn't mention a lower outer join's LHS.  This still allows the
      chained-outer-joins style that is the normally optimizable case.
      
      I also tightened things up some more in join_is_legal().  It seems to me
      on review that what's really happening in the exception case where we
      ignore a mismatched special join is that we're allowing the proposed join
      to associate into the RHS of the outer join we're comparing it to.  As
      such, we should *always* insist that the proposed join be a left join,
      which eliminates a bunch of rather dubious argumentation.  The case where
      we weren't enforcing that was the one that was already known buggy anyway
      (it had a violatable Assert before the aforesaid commit) so it hardly
      deserves a lot of deference.
      
      Back-patch to all active branches, like the previous patch.  The added
      regression test case failed in all branches back to 9.1, and I think it's
      only an unrelated change in costing calculations that kept 9.0 from
      choosing a broken plan.
      8703059c
    • Robert Haas's avatar
      Fix incorrect calculation in shm_mq_receive. · df0a67f7
      Robert Haas authored
      If some, but not all, of the length word has already been read, and the
      next attempt to read sees exactly the number of bytes needed to complete
      the length word, or fewer, then we'll incorrectly read less than all of
      the available data.
      
      Antonin Houska
      df0a67f7
    • Robert Haas's avatar
      Reduce ProcArrayLock contention by removing backends in batches. · 0e141c0f
      Robert Haas authored
      When a write transaction commits, it must clear its XID advertised via
      the ProcArray, which requires that we hold ProcArrayLock in exclusive
      mode in order to prevent concurrent processes running GetSnapshotData
      from seeing inconsistent results.  When many processes try to commit
      at once, ProcArrayLock must change hands repeatedly, with each
      concurrent process trying to commit waking up to acquire the lock in
      turn.  To make things more efficient, when more than one backend is
      trying to commit a write transaction at the same time, have just one
      of them acquire ProcArrayLock in exclusive mode and clear the XIDs of
      all processes in the group.  Benchmarking reveals that this is much
      more efficient at very high client counts.
      
      Amit Kapila, heavily revised by me, with some review also from Pavan
      Deolasee.
      0e141c0f
    • Kevin Grittner's avatar
      Fix `make installcheck` for serializable transactions. · 253de7e1
      Kevin Grittner authored
      Commit e5550d5f added some new
      tests for ALTER TABLE which involved table scans.  When
      default_transaction_isolation = 'serializable' these acquire
      relation-level SIReadLocks.  The test results didn't cope with
      that.  Add SIReadLock as the minimum lock level for purposes of
      these tests.
      
      This could also be fixed by excluding this type of lock from the
      my_locks view, but it would be a bug for SIReadLock to show up for
      a relation which was not otherwise locked, so do it this way to
      allow that sort of condition to cause a regression test failure.
      
      There is some question whether we could avoid taking SIReadLocks
      during these operations, but confirming the safety of that and
      figuring out how to avoid the locks is not trivial, and would be
      a separate patch.
      
      Backpatch to 9.4 where the new tests were added.
      253de7e1
    • Andres Freund's avatar
      Improve includes introduced in the replication origins patch. · 3a145757
      Andres Freund authored
      pg_resetxlog.h contained two superfluous includes, origin.h superfluously
      depended on logical.h, and pg_xlogdump's rmgrdesc.h only indirectly
      included origin.h.
      
      Backpatch: 9.5, where replication origins were introduced.
      3a145757
    • Bruce Momjian's avatar
      e641d7b2
    • Noah Misch's avatar
      Reconcile nodes/*funcs.c with recent work. · b8fe12a8
      Noah Misch authored
      A few of the discrepancies had semantic significance, but I did not
      track down the resulting user-visible bugs, if any.  Back-patch to 9.5,
      where all but one discrepancy appeared.  The _equalCreateEventTrigStmt()
      situation dates to 9.3 but does not affect semantics.
      
      catversion bump due to readfuncs.c field order changes.
      b8fe12a8
    • Noah Misch's avatar
      Link $(WIN32RES) into single-file modules only when PGFILEDESC is set. · c2617066
      Noah Misch authored
      Commit 0ffc201a included this object
      unconditionally.  Being unprepared for that, most external, single-file
      modules failed to build.  This better aligns the GNU make build system
      with the heuristic in the MSVC build's Project::AddDirResourceFile().
      In-tree, installed modules set PGFILEDESC, so they will see no change.
      Also, under PGXS, omit the nonfunctioning rule to build win32ver.rc.
      Back-patch to 9.5, where the aforementioned commit first appeared.
      c2617066
  3. 05 Aug, 2015 9 commits
    • Andrew Dunstan's avatar
      Allow pg_rewind tap tests to run with older File::Path versions · 7c29764a
      Andrew Dunstan authored
      Older versions have rmtree but not remove_tree. The one-argument forms
      of these are equivalent, so replace remove_tree with rmtree. This allows
      the tests to be run on oldish Msys systems.
      7c29764a
    • Andrew Dunstan's avatar
      Remove carriage returns from certain tap test output under Msys · ff85fc8d
      Andrew Dunstan authored
      These were causing spurious test failures.
      ff85fc8d
    • Alvaro Herrera's avatar
      Fix BRIN to use SnapshotAny during summarization · 2834855c
      Alvaro Herrera authored
      For correctness of summarization results, it is critical that the
      snapshot used during the summarization scan is able to see all tuples
      that are live to all transactions -- including tuples inserted or
      deleted by in-progress transactions.  Otherwise, it would be possible
      for a transaction to insert a tuple, then idle for a long time while a
      concurrent transaction executes summarization of the range: this would
      result in the inserted value not being considered in the summary.
      Previously we were trying to use a MVCC snapshot in conjunction with
      adding a "placeholder" tuple in the index: the snapshot would see all
      committed tuples, and the placeholder tuple would catch insertions by
      any new inserters.  The hole is that prior insertions by transactions
      that are still in progress by the time the MVCC snapshot was taken were
      ignored.
      
      Kevin Grittner reported this as a bogus error message during vacuum with
      default transaction isolation mode set to repeatable read (because the
      error report mentioned a function name not being invoked during), but
      the problem is larger than that.
      
      To fix, tweak IndexBuildHeapRangeScan to have a new mode that behaves
      the way we need using SnapshotAny visibility rules.  This change
      simplifies the BRIN code a bit, mainly by removing large comments that
      were mistaken.  Instead, rely on the SnapshotAny semantics to provide
      what it needs.  (The business about a placeholder tuple needs to remain:
      that covers the case that a transaction inserts a a tuple in a page that
      summarization already scanned.)
      
      Discussion: https://www.postgresql.org/message-id/20150731175700.GX2441@postgresql.org
      
      In passing, remove a couple of unused declarations from brin.h and
      reword a comment to be proper English.  This part submitted by Kevin
      Grittner.
      
      Backpatch to 9.5, where BRIN was introduced.
      2834855c
    • Tom Lane's avatar
      Make real sure we don't reassociate joins into or out of SEMI/ANTI joins. · 6af9ee4c
      Tom Lane authored
      Per the discussion in optimizer/README, it's unsafe to reassociate anything
      into or out of the RHS of a SEMI or ANTI join.  An example from Piotr
      Stefaniak showed that join_is_legal() wasn't sufficiently enforcing this
      rule, so lock it down a little harder.
      
      I couldn't find a reasonably simple example of the optimizer trying to
      do this, so no new regression test.  (Piotr's example involved the random
      search in GEQO accidentally trying an invalid case and triggering a sanity
      check way downstream in clause selectivity estimation, which did not seem
      like a sequence of events that would be useful to memorialize in a
      regression test as-is.)
      
      Back-patch to all active branches.
      6af9ee4c
    • Andres Freund's avatar
      Fix typo in commit de6fd1c8. · 18382ae7
      Andres Freund authored
      Per buildfarm members mandrill and hornet.
      18382ae7
    • Andres Freund's avatar
      Rely on inline functions even if that causes warnings in older compilers. · de6fd1c8
      Andres Freund authored
      So far we have worked around the fact that some very old compilers do
      not support 'inline' functions by only using inline functions
      conditionally (or not at all). Since such compilers are very rare by
      now, we have decided to rely on inline functions from 9.6 onwards.
      
      To avoid breaking these old compilers inline is defined away when not
      supported. That'll cause "function x defined but not used" type of
      warnings, but since nobody develops on such compilers anymore that's
      ok.
      
      This change in policy will allow us to more easily employ inline
      functions.
      
      I chose to remove code previously conditional on PG_USE_INLINE as it
      seemed confusing to have code dependent on a define that's always
      defined.
      
      Blacklisting of compilers, like in c53f7387, now has to be done
      differently. A platform template can define PG_FORCE_DISABLE_INLINE to
      force inline to be defined empty.
      
      Discussion: 20150701161447.GB30708@awork2.anarazel.de
      de6fd1c8
    • Andres Freund's avatar
      Fix debug message output when connecting to a logical slot. · a855118b
      Andres Freund authored
      Previously the message erroneously printed the same LSN twice as the
      assignment to the start_lsn variable was before the message. Correct
      that.
      
      Reported-By: Marko Tiikkaja
      Author: Marko Tiikkaja
      Backpatch: 9.5, where logical decoding was introduced
      a855118b
    • Andres Freund's avatar
      Fix comment atomics.h. · 073082bb
      Andres Freund authored
      I appear to accidentally have switched the comments for
      pg_atomic_write_u32 and pg_atomic_read_u32 around. Also fix some minor
      typos I found while fixing.
      
      Noticed-By: Amit Kapila
      Backpatch: 9.5
      073082bb
    • Tom Lane's avatar
      Docs: add an explicit example about controlling overall greediness of REs. · 1b5d34ca
      Tom Lane authored
      Per discussion of bug #13538.
      1b5d34ca
  4. 04 Aug, 2015 7 commits
    • Tom Lane's avatar
      Fix pg_dump to dump shell types. · 3bdd7f90
      Tom Lane authored
      Per discussion, it really ought to do this.  The original choice to
      exclude shell types was probably made in the dark ages before we made
      it harder to accidentally create shell types; but that was in 7.3.
      
      Also, cause the standard regression tests to leave a shell type behind,
      for convenience in testing the case in pg_dump and pg_upgrade.
      
      Back-patch to all supported branches.
      3bdd7f90
    • Tom Lane's avatar
      Fix bogus "out of memory" reports in tuplestore.c. · 8ea3e7a7
      Tom Lane authored
      The tuplesort/tuplestore memory management logic assumed that the chunk
      allocation overhead for its memtuples array could not increase when
      increasing the array size.  This is and always was true for tuplesort,
      but we (I, I think) blindly copied that logic into tuplestore.c without
      noticing that the assumption failed to hold for the much smaller array
      elements used by tuplestore.  Given rather small work_mem, this could
      result in an improper complaint about "unexpected out-of-memory situation",
      as reported by Brent DeSpain in bug #13530.
      
      The easiest way to fix this is just to increase tuplestore's initial
      array size so that the assumption holds.  Rather than relying on magic
      constants, though, let's export a #define from aset.c that represents
      the safe allocation threshold, and make tuplestore's calculation depend
      on that.
      
      Do the same in tuplesort.c to keep the logic looking parallel, even though
      tuplesort.c isn't actually at risk at present.  This will keep us from
      breaking it if we ever muck with the allocation parameters in aset.c.
      
      Back-patch to all supported versions.  The error message doesn't occur
      pre-9.3, not so much because the problem can't happen as because the
      pre-9.3 tuplestore code neglected to check for it.  (The chance of
      trouble is a great deal larger as of 9.3, though, due to changes in the
      array-size-increasing strategy.)  However, allowing LACKMEM() to become
      true unexpectedly could still result in less-than-desirable behavior,
      so let's patch it all the way back.
      8ea3e7a7
    • Tom Lane's avatar
      Fix a PlaceHolderVar-related oversight in star-schema planning patch. · 85e5e222
      Tom Lane authored
      In commit b514a746, I changed the planner
      so that it would allow nestloop paths to remain partially parameterized,
      ie the inner relation might need parameters from both the current outer
      relation and some upper-level outer relation.  That's fine so long as we're
      talking about distinct parameters; but the patch also allowed creation of
      nestloop paths for cases where the inner relation's parameter was a
      PlaceHolderVar whose eval_at set included the current outer relation and
      some upper-level one.  That does *not* work.
      
      In principle we could allow such a PlaceHolderVar to be evaluated at the
      lower join node using values passed down from the upper relation along with
      values from the join's own outer relation.  However, nodeNestloop.c only
      supports simple Vars not arbitrary expressions as nestloop parameters.
      createplan.c is also a few bricks shy of being able to handle such cases;
      it misplaces the PlaceHolderVar parameters in the plan tree, which is why
      the visible symptoms of this bug are "plan should not reference subplan's
      variable" and "failed to assign all NestLoopParams to plan nodes" planner
      errors.
      
      Adding the necessary complexity to make this work doesn't seem like it
      would be repaid in significantly better plans, because in cases where such
      a PHV exists, there is probably a corresponding join order constraint that
      would allow a good plan to be found without using the star-schema exception.
      Furthermore, adding complexity to nodeNestloop.c would create a run-time
      penalty even for plans where this whole consideration is irrelevant.
      So let's just reject such paths instead.
      
      Per fuzz testing by Andreas Seltenreich; the added regression test is based
      on his example query.  Back-patch to 9.2, like the previous patch.
      85e5e222
    • Robert Haas's avatar
      Cap wal_buffers to avoid a server crash when it's set very large. · 369342cf
      Robert Haas authored
      It must be possible to multiply wal_buffers by XLOG_BLCKSZ without
      overflowing int, or calculations in StartupXLOG will go badly wrong
      and crash the server.  Avoid that by imposing a maximum value on
      wal_buffers.  This will be just under 2GB, assuming the usual value
      for XLOG_BLCKSZ.
      
      Josh Berkus, per an analysis by Andrew Gierth.
      369342cf
    • Robert Haas's avatar
      Tab completion for CREATE SEQUENCE. · 158e3bc8
      Robert Haas authored
      Vik Fearing, reviewed by Brendan Jurd, Michael Paquier, and myself
      158e3bc8
    • Robert Haas's avatar
      Update comment to match behavior of latest code. · a6a23578
      Robert Haas authored
      Peter Geoghegan
      a6a23578
    • Heikki Linnakangas's avatar
      Share transition state between different aggregates when possible. · 804163bc
      Heikki Linnakangas authored
      If there are two different aggregates in the query with same inputs, and
      the aggregates have the same initial condition and transition function,
      only calculate the state value once, and only call the final functions
      separately. For example, AVG(x) and SUM(x) aggregates have the same
      transition function, which accumulates the sum and number of input tuples.
      For a query like "SELECT AVG(x), SUM(x) FROM x", we can therefore
      accumulate the state function only once, which gives a nice speedup.
      
      David Rowley, reviewed and edited by me.
      804163bc
  5. 03 Aug, 2015 8 commits
    • Stephen Frost's avatar
      RLS: Keep deny policy when only restrictive exist · dee0200f
      Stephen Frost authored
      Only remove the default deny policy when a permissive policy exists
      (either from the hook or defined by the user).  If only restrictive
      policies exist then no rows will be visible, as restrictive policies
      shouldn't make rows visible.  To address this requirement, a single
      "USING (true)" permissive policy can be created.
      
      Update the test_rls_hooks regression tests to create the necessary
      "USING (true)" permissive policy.
      
      Back-patch to 9.5 where RLS was added.
      
      Per discussion with Dean.
      dee0200f
    • Tom Lane's avatar
      Update 9.5 release notes through today. · ecc2d16b
      Tom Lane authored
      ecc2d16b
    • Joe Conway's avatar
      Fix psql \d output of policies. · c3cc844f
      Joe Conway authored
      psql neglected to wrap parenthesis around USING and WITH CHECK
      expressions -- fixed. Back-patched to 9.5 where RLS policies were
      introduced.
      c3cc844f
    • Fujii Masao's avatar
      Make recovery rename tablespace_map to *.old if backup_label is not present. · dd85acf0
      Fujii Masao authored
      If tablespace_map file is present without backup_label file, there is
      no use of such file.  There is no harm in retaining it, but it is better
      to get rid of the map file so that we don't have any redundant file
      in data directory and it will avoid any sort of confusion. It seems
      prudent though to just rename the file out of the way rather than
      delete it completely, also we ignore any error that occurs in rename
      operation as even if map file is present without backup_label file,
      it is harmless.
      
      Back-patch to 9.5 where tablespace_map file was introduced.
      
      Amit Kapila, reviewed by Robert Haas, Alvaro Herrera and me.
      dd85acf0
    • Heikki Linnakangas's avatar
      Fix pg_rewind when pg_xlog is a symlink. · 0e42397f
      Heikki Linnakangas authored
      pg_xlog is often a symlink, typically to a different filesystem. Don't
      get confused and comlain about by that, and just always pretend that it's a
      normal directory, even if it's really a symlink.
      
      Also add a test case for this.
      
      Backpatch to 9.5.
      0e42397f
    • Heikki Linnakangas's avatar
      Clean up pg_rewind regression test script. · 69b7a35c
      Heikki Linnakangas authored
      Since commit 01f6bb4b, TestLib.pm has exported path to tmp_check directory,
      so let's use that also for the pg_rewind test clusters etc.
      
      Also, in master, the $tempdir_short variable has not been used since commit
      13d856e1, which moved the initdb-running code to TestLib.pm.
      
      Backpatch to 9.5.
      69b7a35c
    • Tom Lane's avatar
      Make modules/test_ddl_deparse/.gitignore match its siblings. · e2b49db0
      Tom Lane authored
      Not sure why /tmp_check/ was omitted from this one, but even if it
      isn't really needed right now, it's inconsistent not to include it.
      e2b49db0
    • Tom Lane's avatar
      contrib/isn now needs a .gitignore file. · fd7ed26c
      Tom Lane authored
      Oversight in commit cb3384a0.
      Back-patch to 9.1, like that commit.
      fd7ed26c