1. 12 Jul, 2019 3 commits
    • Thomas Munro's avatar
      Warn if wal_level is too low when creating a publication. · b31fbe85
      Thomas Munro authored
      Provide a hint to users that they need to increase wal_level before
      subscriptions can work.
      
      Author: Lucas Viecelli, with some adjustments by Thomas Munro
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/CAPjy-57rn5Y9g4e5u--eSOP-7P4QrE9uOZmT2ZcUebF8qxsYhg%40mail.gmail.com
      b31fbe85
    • Tom Lane's avatar
      Fix get_actual_variable_range() to cope with broken HOT chains. · d3751adc
      Tom Lane authored
      Commit 3ca930fc modified get_actual_variable_range() to use a new
      "SnapshotNonVacuumable" snapshot type for selecting tuples that it
      would consider valid.  However, because that snapshot type can accept
      recently-dead tuples, this caused a bug when using a recently-created
      index: we might accept a recently-dead tuple that is an early member
      of a broken HOT chain and does not actually match the index entry.
      Then, the data extracted from the heap tuple would not necessarily be
      an endpoint value of the column; it could even be NULL, leading to
      get_actual_variable_range() itself reporting "found unexpected null
      value in index".  Even without an error, this could lead to poor
      plan choices due to an erroneous notion of the endpoint value.
      
      We can improve matters by changing the code to use the index-only
      scan technique (which didn't exist when get_actual_variable_range was
      originally written).  If any of the tuples in a HOT chain are live
      enough to satisfy SnapshotNonVacuumable, we take the data from the
      index entry, ignoring what is in the heap.  This fixes the problem
      without changing the live-vs-dead-tuple behavior from what was
      intended by commit 3ca930fc.
      
      A side benefit is that for static tables we might not have to touch
      the heap at all (when the extremal value is in an all-visible page).
      In addition, we can save some overhead by not having to create a
      complete ExecutorState, and we don't need to run FormIndexDatum,
      avoiding more cycles as well as the possibility of failure for
      indexes on expressions.  (I'm not sure that this code would ever
      be used to determine the extreme value of an expression, in the
      current state of the planner; but it's definitely possible that
      lower-order columns of the selected index could be expressions.
      So one could construct perhaps-artificial examples in which the
      old code unexpectedly failed due to trying to compute an
      expression's value for a now-dead row.)
      
      Per report from Manuel Rigger.  Back-patch to v11 where commit
      3ca930fc came in.
      
      Discussion: https://postgr.es/m/CA+u7OA7W4NWEhCvftdV6_8bbm2vgypi5nuxfnSEJQqVKFSUoMg@mail.gmail.com
      d3751adc
    • David Rowley's avatar
      Fix RANGE partition pruning with multiple boolean partition keys · cfde2349
      David Rowley authored
      match_clause_to_partition_key incorrectly would return
      PARTCLAUSE_UNSUPPORTED if a bool qual could not be matched to the current
      partition key.  This was a problem, as it causes the calling function to
      discard the qual and not try to match it to any other partition key.  If
      there was another partition key which did match this qual, then the qual
      would not be checked again and we could fail to prune some partitions.
      
      The worst this could do was to cause partitions not to be pruned when they
      could have been, so there was no danger of incorrect query results here.
      
      Fix this by changing match_boolean_partition_clause to have it return a
      PartClauseMatchStatus rather than a boolean value.  This allows it to
      communicate if the qual is unsupported or if it just does not match this
      particular partition key, previously these two cases were treated the
      same.  Now, if match_clause_to_partition_key is unable to match the qual
      to any other qual type then we can simply return the value from the
      match_boolean_partition_clause call so that the calling function properly
      treats the qual as either unmatched or unsupported.
      
      Reported-by: Rares Salcudean
      Reviewed-by: Amit Langote
      Backpatch-through: 11 where partition pruning was introduced
      Discussion: https://postgr.es/m/CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com
      cfde2349
  2. 11 Jul, 2019 1 commit
  3. 10 Jul, 2019 7 commits
  4. 09 Jul, 2019 5 commits
  5. 08 Jul, 2019 5 commits
  6. 07 Jul, 2019 2 commits
  7. 06 Jul, 2019 5 commits
  8. 05 Jul, 2019 8 commits
  9. 04 Jul, 2019 4 commits
    • Tomas Vondra's avatar
      Simplify pg_mcv_list (de)serialization · 08aa131c
      Tomas Vondra authored
      The serialization format of multivariate MCV lists included alignment in
      order to allow direct access to part of the serialized data, but despite
      multiple fixes (see for example commits d85e0f36 and ea4e1c0e) this
      proved to be problematic.
      
      This commit abandons alignment in the serialized format, and just copies
      everything during deserialization.  We now also track amount of memory
      needed after deserialization (including alignment), which allows us to
      deserialize the MCV list in a single pass.
      
      Bump catversion, as this affects contents of pg_statistic_ext_data.
      
      Backpatch to 12, where multi-column MCV lists were introduced.
      
      Author: Tomas Vondra
      Reviewed-by: Tom Lane
      Discussion: https://postgr.es/m/2201.1561521148@sss.pgh.pa.us
      08aa131c
    • Tomas Vondra's avatar
      Fix pg_mcv_list_items() to produce text[] · 4d66285a
      Tomas Vondra authored
      The function pg_mcv_list_items() returns values stored in MCV items. The
      items may contain columns with different data types, so the function was
      generating text array-like representation, but in an ad-hoc way without
      properly escaping various characters etc.
      
      Fixed by simply building a text[] array, which also makes it easier to
      use from queries etc.
      
      Requires changes to pg_proc entry, so bump catversion.
      
      Backpatch to 12, where multi-column MCV lists were introduced.
      
      Author: Tomas Vondra
      Reviewed-by: Dean Rasheed
      Discussion: https://postgr.es/m/20190618205920.qtlzcu73whfpfqne@development
      4d66285a
    • Tomas Vondra's avatar
      Speed-up build of MCV lists with many distinct values · e365a581
      Tomas Vondra authored
      When building multi-column MCV lists, we compute base frequency for each
      item, i.e. a product of per-column frequencies for values from the item.
      As a value may be in multiple groups, the code was scanning the whole
      array of groups while adding items to the MCV list.  This works fine as
      long as the number of distinct groups is small, but it's easy to trigger
      trigger O(N^2) behavior, especially after increasing statistics target.
      
      This commit precomputes frequencies for values in all columns, so that
      when computing the base frequency it's enough to make a simple bsearch
      lookup in the array.
      
      Backpatch to 12, where multi-column MCV lists were introduced.
      
      Discussion: https://postgr.es/m/20190618205920.qtlzcu73whfpfqne@development
      e365a581
    • Peter Eisentraut's avatar
      Remove unnecessary casts from size_t to int · d5ab9df7
      Peter Eisentraut authored
      We can use the %zu format specifier directly, no need to cast to int.
      d5ab9df7