1. 21 Sep, 2017 1 commit
  2. 20 Sep, 2017 13 commits
  3. 19 Sep, 2017 14 commits
  4. 18 Sep, 2017 7 commits
    • Tom Lane's avatar
      Minor code-cleanliness improvements for btree. · eb5c404b
      Tom Lane authored
      Make the btree page-flags test macros (P_ISLEAF and friends) return clean
      boolean values, rather than values that might not fit in a bool.  Use them
      in a few places that were randomly referencing the flag bits directly.
      
      In passing, change access/nbtree/'s only direct use of BUFFER_LOCK_SHARE to
      BT_READ.  (Some think we should go the other way, but as long as we have
      BT_READ/BT_WRITE, let's use them consistently.)
      
      Masahiko Sawada, reviewed by Doug Doole
      
      Discussion: https://postgr.es/m/CAD21AoBmWPeN=WBB5Jvyz_Nt3rmW1ebUyAnk3ZbJP3RMXALJog@mail.gmail.com
      eb5c404b
    • Tom Lane's avatar
      Make ExplainOpenGroup and ExplainCloseGroup public. · 66917bfa
      Tom Lane authored
      Extensions with custom plan nodes might like to use these in their
      EXPLAIN output.
      
      Hadi Moshayedi
      
      Discussion: https://postgr.es/m/CA+_kT_dU-rHCN0u6pjA6bN5CZniMfD=-wVqPY4QLrKUY_uJq5w@mail.gmail.com
      66917bfa
    • Tom Lane's avatar
      Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. · 4bd19946
      Tom Lane authored
      By project convention, these names should include "P" when dealing with a
      pointer type; that is, if the result of a GETARG macro is of type FOO *,
      it should be called PG_GETARG_FOO_P not just PG_GETARG_FOO.  Some newer
      types such as JSONB and ranges had not followed the convention, and a
      number of contrib modules hadn't gotten that memo either.  Rename the
      offending macros to improve consistency.
      
      In passing, fix a few places that thought PG_DETOAST_DATUM() returns
      a Datum; it does not, it returns "struct varlena *".  Applying
      DatumGetPointer to that happens not to cause any bad effects today,
      but it's formally wrong.  Also, adjust an ltree macro that was designed
      without any thought for what pgindent would do with it.
      
      This is all cosmetic and shouldn't have any impact on generated code.
      
      Mark Dilger, some further tweaks by me
      
      Discussion: https://postgr.es/m/EA5676F4-766F-4F38-8348-ECC7DB427C6A@gmail.com
      4bd19946
    • Tom Lane's avatar
      Fix, or at least ameliorate, bugs in logicalrep_worker_launch(). · 3e1683d3
      Tom Lane authored
      If we failed to get a background worker slot, the code just walked
      away from the logicalrep-worker slot it already had, leaving that
      looking like the worker is still starting up.  This led to an indefinite
      hang in subscription startup, as reported by Thomas Munro.  We must
      release the slot on failure.
      
      Also fix a thinko: we must capture the worker slot's generation before
      releasing LogicalRepWorkerLock the first time, else testing to see if
      it's changed is pretty meaningless.
      
      BTW, the CHECK_FOR_INTERRUPTS() in WaitForReplicationWorkerAttach is a
      ticking time bomb, even without considering the possibility of elog(ERROR)
      in one of the other functions it calls.  Really, this entire business needs
      a redesign with some actual thought about error recovery.  But for now
      I'm just band-aiding the case observed in testing.
      
      Back-patch to v10 where this code was added.
      
      Discussion: https://postgr.es/m/CAEepm=2bP3TBMFBArP6o20AZaRduWjMnjCjt22hSdnA-EvrtCw@mail.gmail.com
      3e1683d3
    • Peter Eisentraut's avatar
      4b17c894
    • Peter Eisentraut's avatar
      d31892e2
    • Peter Eisentraut's avatar
      Fix DROP SUBSCRIPTION hang · 8edacab2
      Peter Eisentraut authored
      When ALTER SUBSCRIPTION DISABLE is run in the same transaction before
      DROP SUBSCRIPTION, the latter will hang because workers will still be
      running, not having seen the DISABLE committed, and DROP SUBSCRIPTION
      will wait until the workers have vacated the replication origin slots.
      
      Previously, DROP SUBSCRIPTION killed the logical replication workers
      immediately only if it was going to drop the replication slot, otherwise
      it scheduled the worker killing for the end of the transaction, as a
      result of 7e174fa7.  This, however,
      causes the present problem.  To fix, kill the workers immediately in all
      cases.  This covers all cases: A subscription that doesn't have a
      replication slot must be disabled.  It was either disabled in the same
      transaction, or it was already disabled before the current transaction,
      but then there shouldn't be any workers left and this won't make a
      difference.
      Reported-by: default avatarArseny Sher <a.sher@postgrespro.ru>
      Discussion: https://www.postgresql.org/message-id/flat/87mv6av84w.fsf%40ars-thinkpad
      8edacab2
  5. 17 Sep, 2017 5 commits
    • Tom Lane's avatar
      Doc: update v10 release notes through today. · 68ab9acd
      Tom Lane authored
      Add item about number of times statement-level triggers will be fired.
      Rearrange the compatibility items into (what seems to me) a less
      random ordering.
      68ab9acd
    • Tom Lane's avatar
      Allow rel_is_distinct_for() to look through RelabelType below OpExpr. · 6f44fe7f
      Tom Lane authored
      This lets it do the right thing for, eg, varchar columns.
      Back-patch to 9.5 where this logic appeared.
      
      David Rowley, per report from Kim Rose Carlsen
      
      Discussion: https://postgr.es/m/VI1PR05MB17091F9A9876528055D6A827C76D0@VI1PR05MB1709.eurprd05.prod.outlook.com
      6f44fe7f
    • Tom Lane's avatar
      Fix possible dangling pointer dereference in trigger.c. · 27c6619e
      Tom Lane authored
      AfterTriggerEndQuery correctly notes that the query_stack could get
      repalloc'd during a trigger firing, but it nonetheless passes the address
      of a query_stack entry to afterTriggerInvokeEvents, so that if such a
      repalloc occurs, afterTriggerInvokeEvents is already working with an
      obsolete dangling pointer while it scans the rest of the events.  Oops.
      The only code at risk is its "delete_ok" cleanup code, so we can
      prevent unsafe behavior by passing delete_ok = false instead of true.
      
      However, that could have a significant performance penalty, because the
      point of passing delete_ok = true is to not have to re-scan possibly
      a large number of dead trigger events on the next time through the loop.
      There's more than one way to skin that cat, though.  What we can do is
      delete all the "chunks" in the event list except the last one, since
      we know all events in them must be dead.  Deleting the chunks is work
      we'd have had to do later in AfterTriggerEndQuery anyway, and it ends
      up saving rescanning of just about the same events we'd have gotten
      rid of with delete_ok = true.
      
      In v10 and HEAD, we also have to be careful to mop up any per-table
      after_trig_events pointers that would become dangling.  This is slightly
      annoying, but I don't think that normal use-cases will traverse this code
      path often enough for it to be a performance problem.
      
      It's pretty hard to hit this in practice because of the unlikelihood
      of the query_stack getting resized at just the wrong time.  Nonetheless,
      it's definitely a live bug of ancient standing, so back-patch to all
      supported branches.
      
      Discussion: https://postgr.es/m/2891.1505419542@sss.pgh.pa.us
      27c6619e
    • Tom Lane's avatar
      Ensure that BEFORE STATEMENT triggers fire the right number of times. · fd31f9f0
      Tom Lane authored
      Commit 0f79440f introduced mechanism to keep AFTER STATEMENT triggers
      from firing more than once per statement, which was formerly possible
      if more than one FK enforcement action had to be applied to a given
      table.  Add a similar mechanism for BEFORE STATEMENT triggers, so that
      we don't have the unexpected situation of firing BEFORE STATEMENT
      triggers more often than AFTER STATEMENT.
      
      As with the previous patch, back-patch to v10.
      
      Discussion: https://postgr.es/m/22315.1505584992@sss.pgh.pa.us
      fd31f9f0
    • Tom Lane's avatar
      Fix bogus size calculation introduced by commit cc5f8136. · cad22075
      Tom Lane authored
      The elements of RecordCacheArray are TupleDesc, not TupleDesc *.
      Those are actually the same size, so that this error is harmless,
      but it's still wrong --- and it might bite us someday, if TupleDesc
      ever became a struct, say.
      
      Per Coverity.
      cad22075