1. 21 Feb, 2019 6 commits
  2. 20 Feb, 2019 7 commits
    • Andrew Gierth's avatar
      Use an unsigned char for bool if we don't use the native bool. · d26a810e
      Andrew Gierth authored
      On (rare) platforms where sizeof(bool) > 1, we need to use our own
      bool, but imported c99 code (such as Ryu) may want to use bool values
      as array subscripts, which elicits warnings if bool is defined as
      char. Using unsigned char instead should work just as well for our
      purposes, and avoid such warnings.
      
      Per buildfarm members prariedog and locust.
      d26a810e
    • Tom Lane's avatar
      Improve planner's understanding of strictness of type coercions. · e04a3905
      Tom Lane authored
      PG type coercions are generally strict, ie a NULL input must produce
      a NULL output (or, in domain cases, possibly an error).  The planner's
      understanding of that was a bit incomplete though, so improve it:
      
      * Teach contain_nonstrict_functions() that CoerceViaIO can always be
      considered strict.  Previously it believed that only if the underlying
      I/O functions were marked strict, which is often but not always true.
      
      * Teach clause_is_strict_for() that CoerceViaIO, ArrayCoerceExpr,
      ConvertRowtypeExpr, CoerceToDomain can all be considered strict.
      Previously it knew nothing about any of them.
      
      The main user-visible impact of this is that IS NOT NULL predicates
      can be proven to hold from expressions involving casts in more cases
      than before, allowing partial indexes with such predicates to be used
      without extra pushups.  This reduces the surprise factor for users,
      who may well be used to ordinary (function-call-based) casts being
      known to be strict.
      
      Per a gripe from Samuel Williams.  This doesn't rise to the level of
      a bug, IMO, so no back-patch.
      
      Discussion: https://postgr.es/m/27571.1550617881@sss.pgh.pa.us
      e04a3905
    • Tom Lane's avatar
      Fix incorrect strictness test for ArrayCoerceExpr expressions. · 1571bc0f
      Tom Lane authored
      The recursion in contain_nonstrict_functions_walker() was done wrong,
      causing the strictness check to be bypassed for a parse node that
      is the immediate input of an ArrayCoerceExpr node.  This could allow,
      for example, incorrect decisions about whether a strict SQL function
      can be inlined.
      
      I didn't add a regression test, because (a) the bug is so narrow
      and (b) I couldn't think of a test case that wasn't dependent on a
      large number of other behaviors, to the point where it would likely
      soon rot to the point of not testing what it was intended to.
      
      I broke this in commit c12d570f, so back-patch to v11.
      
      Discussion: https://postgr.es/m/27571.1550617881@sss.pgh.pa.us
      1571bc0f
    • Alvaro Herrera's avatar
      Make object address handling more robust · 5721b9b3
      Alvaro Herrera authored
      pg_identify_object_as_address crashes when passed certain tuples from
      inconsistent system catalogs.  Make it more defensive.
      
      Author: Álvaro Herrera
      Reviewed-by: Michaël Paquier
      Discussion: https://postgr.es/m/20190218202743.GA12392@alvherre.pgsql
      5721b9b3
    • Amit Kapila's avatar
      Doc: Update the documentation for FSM behavior for small tables. · 29d108cd
      Amit Kapila authored
      In commit b0eaa4c5, we have avoided the creation of FSM for small tables.
      So the functions that use FSM to compute the free space can return zero for
      such tables.  This was previously also possible for the cases where the
      vacuum has not been triggered to update FSM.
      
      This commit updates the comments in code and documentation to reflect this
      behavior.
      
      Author: John Naylor
      Reviewed-by: Amit Kapila
      Discussion: https://postgr.es/m/CACPNZCtba-3m1q3A8gxA_vxg=T7gQf7gMbpR4Ciy5LntY-j+0Q@mail.gmail.com
      29d108cd
    • Dean Rasheed's avatar
      Fix DEFAULT-handling in multi-row VALUES lists for updatable views. · 41531e42
      Dean Rasheed authored
      INSERT ... VALUES for a single VALUES row is implemented differently
      from a multi-row VALUES list, which causes inconsistent behaviour in
      the way that DEFAULT items are handled. In particular, when inserting
      into an auto-updatable view on top of a table with a column default, a
      DEFAULT item in a single VALUES row gets correctly replaced with the
      table column's default, but for a multi-row VALUES list it is replaced
      with NULL.
      
      Fix this by allowing rewriteValuesRTE() to leave DEFAULT items in the
      VALUES list untouched if the target relation is an auto-updatable view
      and has no column default, deferring DEFAULT-expansion until the query
      against the base relation is rewritten. For all other types of target
      relation, including tables and trigger- and rule-updatable views, we
      must continue to replace DEFAULT items with NULL in the absence of a
      column default.
      
      This is somewhat complicated by the fact that if an auto-updatable
      view has DO ALSO rules attached, the VALUES lists for the product
      queries need to be handled differently from the original query, since
      the product queries need to act like rule-updatable views whereas the
      original query has auto-updatable view semantics.
      
      Back-patch to all supported versions.
      
      Reported by Roger Curley (bug #15623). Patch by Amit Langote and me.
      
      Discussion: https://postgr.es/m/15623-5d67a46788ec8b7f@postgresql.org
      41531e42
    • Michael Paquier's avatar
      Mark correctly initial slot snapshots with MVCC type when built · 56fadbed
      Michael Paquier authored
      When building an initial slot snapshot, snapshots are marked with
      historic MVCC snapshots as type with the marker field being set in
      SnapBuildBuildSnapshot() but not overriden in SnapBuildInitialSnapshot().
      Existing callers of SnapBuildBuildSnapshot() do not care about the type
      of snapshot used, but extensions calling it actually may, as reported.
      
      While on it, mark correctly the snapshot type when importing one.  This
      is cosmetic as the field is enforced to 0.
      
      Author: Antonin Houska
      Reviewed-by: Álvaro Herrera, Michael Paquier
      Discussion: https://postgr.es/m/23215.1527665193@localhost
      Backpatch-through: 9.4
      56fadbed
  3. 19 Feb, 2019 2 commits
  4. 18 Feb, 2019 10 commits
  5. 17 Feb, 2019 6 commits
    • Thomas Munro's avatar
      Fix race in dsm_unpin_segment() when handles are reused. · 0b55aaac
      Thomas Munro authored
      Teach dsm_unpin_segment() to skip segments that are in the process
      of being destroyed by another backend, when searching for a handle.
      Such a segment cannot possibly be the one we are looking for, even
      if its handle matches.  Another slot might hold a recently created
      segment that has the same handle value by coincidence, and we need
      to keep searching for that one.
      
      The bug caused rare "cannot unpin a segment that is not pinned"
      errors on 10 and 11.  Similar to commit 6c0fb941 for dsm_attach().
      
      Back-patch to 10, where dsm_unpin_segment() landed.
      
      Author: Thomas Munro
      Reported-by: Justin Pryzby
      Tested-by: Justin Pryzby (along with other recent DSA/DSM fixes)
      Discussion: https://postgr.es/m/20190216023854.GF30291@telsasoft.com
      0b55aaac
    • Joe Conway's avatar
      Fix documentation for dblink_error_message() return value · bc6d7eb6
      Joe Conway authored
      The dblink documentation claims that an empty string is returned if there
      has been no error, however OK is actually returned in that case. Also,
      clarify that an async error may not be seen unless dblink_is_busy() or
      dblink_get_result() have been called first.
      
      Backpatch to all supported branches.
      
      Reported-by: realyota
      Backpatch-through: 9.4
      Discussion: https://postgr.es/m/153371978486.1298.2091761143788088262@wrigleys.postgresql.org
      bc6d7eb6
    • Tom Lane's avatar
      Fix CREATE VIEW to allow zero-column views. · a32ca788
      Tom Lane authored
      We should logically have allowed this case when we allowed zero-column
      tables, but it was overlooked.
      
      Although this might be thought a feature addition, it's really a bug
      fix, because it was possible to create a zero-column view via
      the convert-table-to-view code path, and then you'd have a situation
      where dump/reload would fail.  Hence, back-patch to all supported
      branches.
      
      Arrange the added test cases to provide coverage of the related
      pg_dump code paths (since these views will be dumped and reloaded
      during the pg_upgrade regression test).  I also made them test
      the case where pg_dump has to postpone the view rule into post-data,
      which disturbingly had no regression coverage before.
      
      Report and patch by Ashutosh Sharma (test case by me)
      
      Discussion: https://postgr.es/m/CAE9k0PkmHdeSaeZt2ujnb_cKucmK3sDDceDzw7+d5UZoNJPYOg@mail.gmail.com
      a32ca788
    • Joe Conway's avatar
      Mark pg_config() stable rather than immutable · 290e3b77
      Joe Conway authored
      pg_config() has been marked immutable since its inception. As part of a
      larger discussion around the definition of immutable versus stable and
      related implications for marking functions parallel safe raised by
      Andres, the consensus was clearly that pg_config() is stable, since
      it could possibly change output even for the same minor version with
      a recompile or installation of a new binary. So mark it stable.
      
      Theoretically this could/should be backpatched, but it was deemed to be not
      worth the effort since in practice this is very unlikely to cause problems
      in the real world.
      
      Discussion: https://postgr.es/m/20181126234521.rh3grz7aavx2ubjv@alap3.anarazel.de
      290e3b77
    • Tatsuo Ishii's avatar
      Doc: remove ancient comment. · 69e52478
      Tatsuo Ishii authored
      There's a very old comment in rules.sgml added back to 2003.  It
      expected to a feature coming back but it never happened. So now we can
      safely remove the comment. Back-patched to all supported branches.
      
      Discussion: https://postgr.es/m/20190211.191004.219630835457494660.t-ishii%40sraoss.co.jp
      69e52478
    • Noah Misch's avatar
      Fix CLogTruncationLock documentation. · 301de4f7
      Noah Misch authored
      Back-patch to v10, which introduced the lock.
      301de4f7
  6. 16 Feb, 2019 9 commits
    • Noah Misch's avatar
      Suppress another case of MSVC warning 4146. · faee6fae
      Noah Misch authored
      faee6fae
    • Noah Misch's avatar
      In imath.h, replace stdint.h usage with c.h equivalents. · 04a87ae2
      Noah Misch authored
      As things stood, buildfarm member dory failed.  MSVC versions lacking
      stdint.h are unusable for building PostgreSQL, but pg_config.h.win32
      doesn't know that.  Even so, we support other systems lacking stdint.h,
      including buildfarm member gaur.  Per a suggestion from Tom Lane.
      
      Discussion: https://postgr.es/m/9598.1550353336@sss.pgh.pa.us
      04a87ae2
    • Andrew Gierth's avatar
      Remove float8-small-is-zero regression test variant. · 6ee89952
      Andrew Gierth authored
      Since this was also the variant used as an example in the docs, update
      the docs to use float4-misrounded-input as an example instead, since
      that is now the only remaining variant file.
      6ee89952
    • Noah Misch's avatar
      Import changes from IMath versions (1.3, 1.29]. · 48e24ba6
      Noah Misch authored
      Upstream fixed bugs over the years, but none are confirmed to have
      affected pgcrypto.  We're better off naively tracking upstream than
      reactively maintaining a twelve-year-old snapshot of upstream.  Add a
      header comment describing the synchronization procedure.  Discard use of
      INVERT_COMPARE_RESULT(); the domain of the comparisons in question is
      {-1,0,1}, controlled entirely by code in imath.c.
      
      Andrew Gierth reviewed the Makefile change.  Tom Lane reviewed the
      synchronization procedure description.
      
      Discussion: https://postgr.es/m/20190203035704.GA6226@rfd.leadboat.com
      48e24ba6
    • Noah Misch's avatar
      Fix PERMIT_DECLARATION_AFTER_STATEMENT initialization. · d1299aab
      Noah Misch authored
      The defect caused a mere warning and only for gcc versions before 3.4.0.
      d1299aab
    • Tom Lane's avatar
      Allow user control of CTE materialization, and change the default behavior. · 608b167f
      Tom Lane authored
      Historically we've always materialized the full output of a CTE query,
      treating WITH as an optimization fence (so that, for example, restrictions
      from the outer query cannot be pushed into it).  This is appropriate when
      the CTE query is INSERT/UPDATE/DELETE, or is recursive; but when the CTE
      query is non-recursive and side-effect-free, there's no hazard of changing
      the query results by pushing restrictions down.
      
      Another argument for materialization is that it can avoid duplicate
      computation of an expensive WITH query --- but that only applies if
      the WITH query is called more than once in the outer query.  Even then
      it could still be a net loss, if each call has restrictions that
      would allow just a small part of the WITH query to be computed.
      
      Hence, let's change the behavior for WITH queries that are non-recursive
      and side-effect-free.  By default, we will inline them into the outer
      query (removing the optimization fence) if they are called just once.
      If they are called more than once, we will keep the old behavior by
      default, but the user can override this and force inlining by specifying
      NOT MATERIALIZED.  Lastly, the user can force the old behavior by
      specifying MATERIALIZED; this would mainly be useful when the query had
      deliberately been employing WITH as an optimization fence to prevent a
      poor choice of plan.
      
      Andreas Karlsson, Andrew Gierth, David Fetter
      
      Discussion: https://postgr.es/m/87sh48ffhb.fsf@news-spur.riddles.org.uk
      608b167f
    • Andrew Gierth's avatar
      Fix previous MinGW fix. · 79730e2a
      Andrew Gierth authored
      Definitions required for MinGW need to be outside #if _MSC_VER. Oops.
      79730e2a
    • Michael Meskes's avatar
      Add DECLARE STATEMENT support to ECPG. · bd7c95f0
      Michael Meskes authored
      DECLARE STATEMENT is a statement that lets users declare an identifier
      pointing at a connection.  This identifier will be used in other embedded
      dynamic SQL statement such as PREPARE, EXECUTE, DECLARE CURSOR and so on.
      When connecting to a non-default connection, the AT clause can be used in
      a DECLARE STATEMENT once and is no longer needed in every dynamic SQL
      statement.  This makes ECPG applications easier and more efficient.  Moreover,
      writing code without designating connection explicitly improves portability.
      
      Authors: Ideriha-san ("Ideriha, Takeshi" <ideriha.takeshi@jp.fujitsu.com>)
               Kuroda-san ("Kuroda, Hayato" <kuroda.hayato@jp.fujitsu.com>)
      
      Discussion: https://postgr.es/m4E72940DA2BF16479384A86D54D0988A565669DF@G01JPEXMBKW04
      bd7c95f0
    • Tom Lane's avatar
      Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. · 02a6a54e
      Tom Lane authored
      Test for the compiler builtins __builtin_clz, __builtin_ctz, and
      __builtin_popcount, and make use of these in preference to
      handwritten C code if they're available.  Create src/port
      infrastructure for "leftmost one", "rightmost one", and "popcount"
      so as to centralize these decisions.
      
      On x86_64, __builtin_popcount generally won't make use of the POPCNT
      opcode because that's not universally supported yet.  Provide code
      that checks CPUID and then calls POPCNT via asm() if available.
      This requires indirecting through a function pointer, which is
      an annoying amount of overhead for a one-instruction operation,
      but it's probably not worth working harder than this for our
      current use-cases.
      
      I'm not sure we've found all the existing places that could profit
      from this new infrastructure; but we at least touched all the
      ones that used copied-and-pasted versions of the bitmapset.c code,
      and got rid of multiple copies of the associated constant arrays.
      
      While at it, replace c-compiler.m4's one-per-builtin-function
      macros with a single one that can handle all the cases we need
      to worry about so far.  Also, because I'm paranoid, make those
      checks into AC_LINK checks rather than just AC_COMPILE; the
      former coding failed to verify that libgcc has support for the
      builtin, in cases where it's not inline code.
      
      David Rowley, Thomas Munro, Alvaro Herrera, Tom Lane
      
      Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com
      02a6a54e