1. 16 May, 2019 2 commits
    • Tom Lane's avatar
      Fix bogus logic for combining range-partitioned columns during pruning. · 3922f106
      Tom Lane authored
      gen_prune_steps_from_opexps's notion of how to do this was overly
      complicated and underly correct.
      
      Per discussion of a report from Alan Jackson (though this fixes only one
      aspect of that problem).  Back-patch to v11 where this code came in.
      
      Amit Langote
      
      Discussion: https://postgr.es/m/FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com
      3922f106
    • Tom Lane's avatar
      Fix partition pruning to treat stable comparison operators properly. · 4b1fcb43
      Tom Lane authored
      Cross-type comparison operators in a btree or hash opclass might be
      only stable not immutable (this is true of timestamp vs. timestamptz
      for example).  partprune.c ignored this possibility and would perform
      plan-time pruning with them anyway, possibly leading to wrong answers
      if the environment changed between planning and execution.
      
      To fix, teach gen_partprune_steps() to do things differently when
      creating plan-time pruning steps vs. run-time pruning steps.
      analyze_partkey_exprs() also needs an extra check, which is rather
      annoying but now is not the time to restructure things enough to
      avoid that.
      
      While at it, simplify the logic for the plan-time case a little
      by insisting that the comparison value be a Const and nothing else.
      This relies on the assumption that eval_const_expressions will have
      reduced any immutable expression to a Const; which is not quite
      100% true, but certainly any case that comes up often enough to be
      interesting should have simplification logic there.
      
      Also improve a bunch of inadequate/obsolete/wrong comments.
      
      Per discussion of a report from Alan Jackson (though this fixes only one
      aspect of that problem).  Back-patch to v11 where this code came in.
      
      David Rowley, with some further hacking by me
      
      Discussion: https://postgr.es/m/FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com
      4b1fcb43
  2. 15 May, 2019 4 commits
    • Peter Geoghegan's avatar
      Remove obsolete nbtree insertion comment. · 489e431b
      Peter Geoghegan authored
      Remove a Berkeley-era comment above _bt_insertonpg() that admonishes the
      reader to grok Lehman and Yao's paper before making any changes.  This
      made a certain amount of sense back when _bt_insertonpg() was
      responsible for most of the things that are now spread across
      _bt_insertonpg(), _bt_findinsertloc(), _bt_insert_parent(), and
      _bt_split(), but it doesn't work like that anymore.
      
      I believe that this comment alludes to the need to "couple" or "crab"
      buffer locks as we ascend the tree as page splits cascade upwards.  The
      nbtree README already explains this in detail, which seems sufficient.
      Besides, the changes to page splits made by commit 40dae7ec altered
      the exact details of how buffer locks are retained during splits; Lehman
      and Yao's original algorithm seems to release the lock on the left child
      page/buffer slightly earlier than _bt_insertonpg()/_bt_insert_parent()
      can.
      489e431b
    • Tom Lane's avatar
      Remove no-longer-used typedef. · 8a0f0ad5
      Tom Lane authored
      struct ClonedConstraint is no longer needed, so delete it.
      
      Discussion: https://postgr.es/m/18102.1557947143@sss.pgh.pa.us
      8a0f0ad5
    • Peter Geoghegan's avatar
      Reverse order of newitem nbtree candidate splits. · 7505da2f
      Peter Geoghegan authored
      Commit fab25024, which taught nbtree to choose candidate split points
      more carefully, had _bt_findsplitloc() record all possible split points
      in an initial pass over a page that is about to be split.  The order
      that candidate split points were processed and stored in was assumed to
      match the offset number order of split points on an imaginary version of
      the page that contains the same items as the original, but also fits
      newitem (the item that provoked the split precisely because it didn't
      fit).
      
      However, the order of split points in the final array was not quite what
      was expected: the split point that makes newitem the firstright item
      came after the split point that makes newitem the lastleft item -- not
      before.  As a result, _bt_findsplitloc() could get confused about the
      leftmost and rightmost tuples among all possible split points recorded
      for the page.  This seems to have no appreciable impact on the quality
      of the final split point chosen by _bt_findsplitloc(), but it's still
      wrong.
      
      To fix, switch the order in which newitem candidate splits are recorded
      in.  This also makes it possible to describe candidate split points in
      terms of which pair of adjoining tuples enclose the split point within
      _bt_findsplitloc(), making it clearer why it's generally safe for
      _bt_split() to expect lastleft and firstright tuples.
      7505da2f
    • Bruce Momjian's avatar
      docs: properly indent PG 12 release notes · a429164e
      Bruce Momjian authored
      a429164e
  3. 14 May, 2019 20 commits
  4. 13 May, 2019 12 commits
  5. 12 May, 2019 2 commits
    • Tom Lane's avatar
      Fix misoptimization of "{1,1}" quantifiers in regular expressions. · 8a29ed05
      Tom Lane authored
      A bounded quantifier with m = n = 1 might be thought a no-op.  But
      according to our documentation (which traces back to Henry Spencer's
      original man page) it still imposes greediness, or non-greediness in the
      case of the non-greedy variant "{1,1}?", on whatever it's attached to.
      
      This turns out not to work though, because parseqatom() optimizes away
      the m = n = 1 case without regard for whether it's supposed to change
      the greediness of the argument RE.
      
      We can fix this by just not applying the optimization when the greediness
      needs to change; the subsequent general cases handle it fine.
      
      The three cases in which we can still apply the optimization are
      (a) no quantifier, or quantifier does not impose a preference;
      (b) atom has no greediness property, implying it cannot match a
      variable amount of text anyway; or
      (c) quantifier's greediness is same as atom's.
      Note that in most cases where one of these applies, we'd have exited
      earlier in the "not a messy case" fast path.  I think it's now only
      possible to get to the optimization when the atom involves capturing
      parentheses or a non-top-level backref.
      
      Back-patch to all supported branches.  I'd ordinarily be hesitant to
      put a subtle behavioral change into back branches, but in this case
      it's very hard to see a reason why somebody would write "{1,1}?" unless
      they're trying to get the documented change-of-greediness behavior.
      
      Discussion: https://postgr.es/m/5bb27a41-350d-37bf-901e-9d26f5592dd0@charter.net
      8a29ed05
    • Noah Misch's avatar
      Fail pgwin32_message_to_UTF16() for SQL_ASCII messages. · d02768dd
      Noah Misch authored
      The function had been interpreting SQL_ASCII messages as UTF8, throwing
      an error when they were invalid UTF8.  The new behavior is consistent
      with pg_do_encoding_conversion().  This affects LOG_DESTINATION_STDERR
      and LOG_DESTINATION_EVENTLOG, which will send untranslated bytes to
      write() and ReportEventA().  On buildfarm member bowerbird, enabling
      log_connections caused an error whenever the role name was not valid
      UTF8.  Back-patch to 9.4 (all supported versions).
      
      Discussion: https://postgr.es/m/20190512015615.GD1124997@rfd.leadboat.com
      d02768dd