1. 09 Nov, 2018 1 commit
    • Michael Paquier's avatar
      Fix dependency handling of partitions and inheritance for ON COMMIT · 319a8101
      Michael Paquier authored
      This commit fixes a set of issues with ON COMMIT actions when used on
      partitioned tables and tables with inheritance children:
      - Applying ON COMMIT DROP on a partitioned table with partitions or on a
      table with inheritance children caused a failure at commit time, with
      complains about the children being already dropped as all relations are
      dropped one at the same time.
      - Applying ON COMMIT DELETE on a partition relying on a partitioned
      table which uses ON COMMIT DROP would cause the partition truncation to
      fail as the parent is removed first.
      
      The solution to the first problem is to handle the removal of all the
      dependencies in one go instead of dropping relations one-by-one, based
      on a suggestion from Álvaro Herrera.  So instead all the relation OIDs
      to remove are gathered and then processed in one round of multiple
      deletions.
      
      The solution to the second problem is to reorder the actions, with
      truncation happening first and relation drop done after.  Even if it
      means that a partition could be first truncated, then immediately
      dropped if its partitioned table is dropped, this has the merit to keep
      the code simple as there is no need to do existence checks on the
      relations to drop.
      
      Contrary to a manual TRUNCATE on a partitioned table, ON COMMIT DELETE
      does not cascade to its partitions.  The ON COMMIT action defined on
      each partition gets the priority.
      
      Author: Michael Paquier
      Reviewed-by: Amit Langote, Álvaro Herrera, Robert Haas
      Discussion: https://postgr.es/m/68f17907-ec98-1192-f99f-8011400517f5@lab.ntt.co.jp
      Backpatch-through: 10
      319a8101
  2. 08 Nov, 2018 4 commits
    • Tom Lane's avatar
      Disallow setting client_min_messages higher than ERROR. · 3d360e20
      Tom Lane authored
      Previously it was possible to set client_min_messages to FATAL or PANIC,
      which had the effect of suppressing transmission of regular ERROR messages
      to the client.  Perhaps that seemed like a useful option in the past, but
      the trouble with it is that it breaks guarantees that are explicitly made
      in our FE/BE protocol spec about how a query cycle can end.  While libpq
      and psql manage to cope with the omission, that's mostly because they
      are not very bright; client libraries that have more semantic knowledge
      are likely to get confused.  Notably, pgODBC doesn't behave very sanely.
      Let's fix this by getting rid of the ability to set client_min_messages
      above ERROR.
      
      In HEAD, just remove the FATAL and PANIC options from the set of allowed
      enum values for client_min_messages.  (This change also affects
      trace_recovery_messages, but that's OK since these aren't useful values
      for that variable either.)
      
      In the back branches, there was concern that rejecting these values might
      break applications that are explicitly setting things that way.  I'm
      pretty skeptical of that argument, but accommodate it by accepting these
      values and then internally setting the variable to ERROR anyway.
      
      In all branches, this allows a couple of tiny simplifications in the
      logic in elog.c, so do that.
      
      Also respond to the point that was made that client_min_messages has
      exactly nothing to do with the server's logging behavior, and therefore
      does not belong in the "When To Log" subsection of the documentation.
      The "Statement Behavior" subsection is a better match, so move it there.
      
      Jonah Harris and Tom Lane
      
      Discussion: https://postgr.es/m/7809.1541521180@sss.pgh.pa.us
      Discussion: https://postgr.es/m/15479-ef0f4cc2fd995ca2@postgresql.org
      3d360e20
    • Alvaro Herrera's avatar
      Revise attribute handling code on partition creation · 705d433f
      Alvaro Herrera authored
      The original code to propagate NOT NULL and default expressions
      specified when creating a partition was mostly copy-pasted from
      typed-tables creation, but not being a great match it contained some
      duplicity, inefficiency and bugs.
      
      This commit fixes the bug that NOT NULL constraints declared in the
      parent table would not be honored in the partition.  One reported issue
      that is not fixed is that a DEFAULT declared in the child is not used
      when inserting through the parent.  That would amount to a behavioral
      change that's better not back-patched.
      
      This rewrite makes the code simpler:
      
      1. instead of checking for duplicate column names in its own block,
      reuse the original one that already did that;
      
      2. instead of concatenating the list of columns from parent and the one
      declared in the partition and scanning the result to (incorrectly)
      propagate defaults and not-null constraints, just scan the latter
      searching the former for a match, and merging sensibly.  This works
      because we know the list in the parent is already correct and there can
      only be one parent.
      
      This rewrite makes ColumnDef->is_from_parent unused, so it's removed
      on branch master; on released branches, it's kept as an unused field in
      order not to cause ABI incompatibilities.
      
      This commit also adds a test case for creating partitions with
      collations mismatching that on the parent table, something that is
      closely related to the code being patched.  No code change is introduced
      though, since that'd be a behavior change that could break some (broken)
      working applications.
      
      Amit Langote wrote a less invasive fix for the original
      NOT NULL/defaults bug, but while I kept the tests he added, I ended up
      not using his original code.  Ashutosh Bapat reviewed Amit's fix.  Amit
      reviewed mine.
      
      Author: Álvaro Herrera, Amit Langote
      Reviewed-by: Ashutosh Bapat, Amit Langote
      Reported-by: Jürgen Strobel (bug #15212)
      Discussion: https://postgr.es/m/152746742177.1291.9847032632907407358@wrigleys.postgresql.org
      705d433f
    • Andrew Dunstan's avatar
      Adjust valgrind fix in commit 517b0d0b · 12d5f39b
      Andrew Dunstan authored
      lousyjack still wasn't happy. I have tested this modification and it
      worked.
      12d5f39b
    • Michael Paquier's avatar
  3. 07 Nov, 2018 9 commits
  4. 06 Nov, 2018 13 commits
  5. 05 Nov, 2018 6 commits
  6. 04 Nov, 2018 4 commits
  7. 03 Nov, 2018 3 commits
    • Andres Freund's avatar
      Prevent generating EEOP_AGG_STRICT_INPUT_CHECK operations when nargs == 0. · 793beab3
      Andres Freund authored
      This only became a problem with 4c640f4f, which didn't synchronize
      the value agg_strict_input_check.nargs is set to, with the guard
      condition for emitting the operation.
      
      Besides such instructions being unnecessary overhead, currently the
      LLVM JIT provider doesn't support them. It seems more sensible to
      avoid generating such instruction than supporting them. Add assertions
      to make it easier to debug a potential further occurance.
      
      Discussion: https://postgr.es/m/2a505161-2727-2473-7c46-591ed108ac52@email.cz
      Backpatch: 11-, like 4c640f4f.
      793beab3
    • Andres Freund's avatar
      Fix STRICT check for strict aggregates with NULL ORDER BY columns. · 4c640f4f
      Andres Freund authored
      I (Andres) broke this unintentionally in 69c3936a, by checking
      strictness for all input expressions computed for an aggregate, rather
      than just the input for the aggregate transition function.
      
      Reported-By: Ondřej Bouda
      Bisected-By: Tom Lane
      Diagnosed-By: Andrew Gierth
      Discussion: https://postgr.es/m/2a505161-2727-2473-7c46-591ed108ac52@email.cz
      Backpatch: 11-, like 69c3936a
      4c640f4f
    • Tom Lane's avatar
      Make ts_locale.c's character-type functions cope with UTF-16. · 981dc2ba
      Tom Lane authored
      On Windows, in UTF8 database encoding, what char2wchar() produces is
      UTF16 not UTF32, ie, characters above U+FFFF will be represented by
      surrogate pairs.  t_isdigit() and siblings did not account for this
      and failed to provide a large enough result buffer.  That in turn
      led to bogus "invalid multibyte character for locale" errors, because
      contrary to what you might think from char2wchar()'s documentation,
      its Windows code path doesn't cope sanely with buffer overflow.
      
      The solution for t_isdigit() and siblings is pretty clear: provide
      a 3-wchar_t result buffer not 2.
      
      char2wchar() also needs some work to provide more consistent, and more
      accurately documented, buffer overrun behavior.  But that's a bigger job
      and it doesn't actually have any immediate payoff, so leave it for later.
      
      Per bug #15476 from Kenji Uno, who deserves credit for identifying the
      cause of the problem.  Back-patch to all active branches.
      
      Discussion: https://postgr.es/m/15476-4314f480acf0f114@postgresql.org
      981dc2ba