1. 05 Nov, 2014 3 commits
    • Robert Haas's avatar
      Fix thinko in commit 2bd9e412. · c30be978
      Robert Haas authored
      Obviously, every translation unit should not be declaring this
      separately.  It needs to be PGDLLIMPORT as well, to avoid breaking
      third-party code that uses any of the functions that the commit
      mentioned above changed to macros.
      c30be978
    • Tom Lane's avatar
      Make CREATE TYPE print warnings if a datatype's I/O functions are volatile. · 465d7e18
      Tom Lane authored
      This is a followup to commit 43ac12c6,
      which added regression tests checking that I/O functions of built-in
      types are not marked volatile.  Complaining in CREATE TYPE should push
      developers of add-on types to fix any misdeclared functions in their
      types.  It's just a warning not an error, to avoid creating upgrade
      problems for what might be just cosmetic mis-markings.
      
      Aside from adding the warning code, fix a number of types that were
      sloppily created in the regression tests.
      465d7e18
    • Tom Lane's avatar
      Fix volatility markings of some contrib I/O functions. · 66c029c8
      Tom Lane authored
      In general, datatype I/O functions are supposed to be immutable or at
      worst stable.  Some contrib I/O functions were, through oversight, not
      marked with any volatility property at all, which made them VOLATILE.
      Since (most of) these functions actually behave immutably, the erroneous
      marking isn't terribly harmful; but it can be user-visible in certain
      circumstances, as per a recent bug report from Joe Van Dyk in which a
      cast to text was disallowed in an expression index definition.
      
      To fix, just adjust the declarations in the extension SQL scripts.  If we
      were being very fussy about this, we'd bump the extension version numbers,
      but that seems like more trouble (for both developers and users) than the
      problem is worth.
      
      A fly in the ointment is that chkpass_in actually is volatile, because
      of its use of random() to generate a fresh salt when presented with a
      not-yet-encrypted password.  This is bad because of the general assumption
      that I/O functions aren't volatile: the consequence is that records or
      arrays containing chkpass elements may have input behavior a bit different
      from a bare chkpass column.  But there seems no way to fix this without
      breaking existing usage patterns for chkpass, and the consequences of the
      inconsistency don't seem bad enough to justify that.  So for the moment,
      just document it in a comment.
      
      Since we're not bumping version numbers, there seems no harm in
      back-patching these fixes; at least future installations will get the
      functions marked correctly.
      66c029c8
  2. 04 Nov, 2014 4 commits
    • Peter Eisentraut's avatar
      doc: Move misplaced paragraph · e809fa2c
      Peter Eisentraut authored
      e809fa2c
    • Tom Lane's avatar
      Drop no-longer-needed buffers during ALTER DATABASE SET TABLESPACE. · 33f80f84
      Tom Lane authored
      The previous coding assumed that we could just let buffers for the
      database's old tablespace age out of the buffer arena naturally.
      The folly of that is exposed by bug #11867 from Marc Munro: the user could
      later move the database back to its original tablespace, after which any
      still-surviving buffers would match lookups again and appear to contain
      valid data.  But they'd be missing any changes applied while the database
      was in the new tablespace.
      
      This has been broken since ALTER SET TABLESPACE was introduced, so
      back-patch to all supported branches.
      33f80f84
    • Heikki Linnakangas's avatar
      Switch to CRC-32C in WAL and other places. · 5028f22f
      Heikki Linnakangas authored
      The old algorithm was found to not be the usual CRC-32 algorithm, used by
      Ethernet et al. We were using a non-reflected lookup table with code meant
      for a reflected lookup table. That's a strange combination that AFAICS does
      not correspond to any bit-wise CRC calculation, which makes it difficult to
      reason about its properties. Although it has worked well in practice, seems
      safer to use a well-known algorithm.
      
      Since we're changing the algorithm anyway, we might as well choose a
      different polynomial. The Castagnoli polynomial has better error-correcting
      properties than the traditional CRC-32 polynomial, even if we had
      implemented it correctly. Another reason for picking that is that some new
      CPUs have hardware support for calculating CRC-32C, but not CRC-32, let
      alone our strange variant of it. This patch doesn't add any support for such
      hardware, but a future patch could now do that.
      
      The old algorithm is kept around for tsquery and pg_trgm, which use the
      values in indexes that need to remain compatible so that pg_upgrade works.
      While we're at it, share the old lookup table for CRC-32 calculation
      between hstore, ltree and core. They all use the same table, so might as
      well.
      5028f22f
    • Heikki Linnakangas's avatar
      Remove support for 64-bit CRC. · 404bc51c
      Heikki Linnakangas authored
      It hasn't been used for anything for a long time.
      404bc51c
  3. 03 Nov, 2014 8 commits
  4. 02 Nov, 2014 1 commit
  5. 01 Nov, 2014 1 commit
  6. 31 Oct, 2014 4 commits
  7. 30 Oct, 2014 3 commits
    • Robert Haas's avatar
      Extend dsm API with a new function dsm_unpin_mapping. · f7102b04
      Robert Haas authored
      This reassociates a dynamic shared memory handle previous passed to
      dsm_pin_mapping with the current resource owner, so that it will be
      cleaned up at the end of the current query.
      
      Patch by me.  Review of the function name by Andres Freund, Amit
      Kapila, Jim Nasby, Petr Jelinek, and Álvaro Herrera.
      f7102b04
    • Tom Lane's avatar
      Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats. · fd0f651a
      Tom Lane authored
      As noted by Noah Misch, my initial cut at fixing bug #11638 didn't cover
      all cases where ANALYZE might be invoked in an unsafe context.  We need to
      test the result of IsInTransactionChain not IsTransactionBlock; which is
      notationally a pain because IsInTransactionChain requires an isTopLevel
      flag, which would have to be passed down through several levels of callers.
      I chose to pass in_outer_xact (ie, the result of IsInTransactionChain)
      rather than isTopLevel per se, as that seemed marginally more apropos
      for the intermediate functions to know about.
      fd0f651a
    • Robert Haas's avatar
      "Pin", rather than "keep", dynamic shared memory mappings and segments. · 6057c212
      Robert Haas authored
      Nobody seemed concerned about this naming when it originally went in,
      but there's a pending patch that implements the opposite of
      dsm_keep_mapping, and the term "unkeep" was judged unpalatable.
      "unpin" has existing precedent in the PostgreSQL code base, and the
      English language, so use this terminology instead.
      
      Per discussion, back-patch to 9.4.
      6057c212
  8. 29 Oct, 2014 4 commits
    • Peter Eisentraut's avatar
      Remove use of TAP subtests · 7912f9b7
      Peter Eisentraut authored
      They turned out to be too much of a portability headache, because they
      need a fairly new version of Test::More to work properly.
      7912f9b7
    • Tom Lane's avatar
      Avoid corrupting tables when ANALYZE inside a transaction is rolled back. · e0722d9c
      Tom Lane authored
      VACUUM and ANALYZE update the target table's pg_class row in-place, that is
      nontransactionally.  This is OK, more or less, for the statistical columns,
      which are mostly nontransactional anyhow.  It's not so OK for the DDL hint
      flags (relhasindex etc), which might get changed in response to
      transactional changes that could still be rolled back.  This isn't a
      problem for VACUUM, since it can't be run inside a transaction block nor
      in parallel with DDL on the table.  However, we allow ANALYZE inside a
      transaction block, so if the transaction had earlier removed the last
      index, rule, or trigger from the table, and then we roll back the
      transaction after ANALYZE, the table would be left in a corrupted state
      with the hint flags not set though they should be.
      
      To fix, suppress the hint-flag updates if we are InTransactionBlock().
      This is safe enough because it's always OK to postpone hint maintenance
      some more; the worst-case consequence is a few extra searches of pg_index
      et al.  There was discussion of instead using a transactional update,
      but that would change the behavior in ways that are not all desirable:
      in most scenarios we're better off keeping ANALYZE's statistical values
      even if the ANALYZE itself rolls back.  In any case we probably don't want
      to change this behavior in back branches.
      
      Per bug #11638 from Casey Shobe.  This has been broken for a good long
      time, so back-patch to all supported branches.
      
      Tom Lane and Michael Paquier, initial diagnosis by Andres Freund
      e0722d9c
    • Robert Haas's avatar
      Avoid setup work for invalidation messages at start-of-(sub)xact. · 6cb4afff
      Robert Haas authored
      Instead of initializing a new TransInvalidationInfo for every
      transaction or subtransaction, we can just do it for those
      transactions or subtransactions that actually need to queue
      invalidation messages.  That also avoids needing to free those
      entries at the end of a transaction or subtransaction that does
      not generate any invalidation messages, which is by far the
      common case.
      
      Patch by me.  Review by Simon Riggs and Andres Freund.
      6cb4afff
    • Heikki Linnakangas's avatar
      Reset error message at PQreset() · 8f8314b5
      Heikki Linnakangas authored
      If you call PQreset() repeatedly, and the connection cannot be
      re-established, the error messages from the failed connection attempts
      kept accumulating in the error string.
      
      Fixes bug #11455 reported by Caleb Epstein. Backpatch to all supported
      versions.
      8f8314b5
  9. 28 Oct, 2014 2 commits
    • Tom Lane's avatar
      Remove obsolete commentary. · a00d468e
      Tom Lane authored
      Since we got rid of non-MVCC catalog scans, the fourth reason given for
      using a non-transactional update in index_update_stats() is obsolete.
      The other three are still good, so we're not going to change the code,
      but fix the comment.
      a00d468e
    • Heikki Linnakangas's avatar
      Remove unnecessary assignment. · 18f158ef
      Heikki Linnakangas authored
      Reported by MauMau.
      18f158ef
  10. 27 Oct, 2014 5 commits
    • Noah Misch's avatar
      MinGW: Include .dll extension in .def file LIBRARY commands. · c0e19036
      Noah Misch authored
      Newer toolchains append the extension implicitly if missing, but
      buildfarm member narwhal (gcc 3.4.2, ld 2.15.91 20040904) does not.
      This affects most core libraries having an exports.txt file, namely
      libpq and the ECPG support libraries.  On Windows Server 2003, Windows
      API functions that load and unload DLLs internally will mistakenly
      unload a libpq whose DLL header reports "LIBPQ" instead of "LIBPQ.dll".
      When, subsequently, control would return to libpq, the backend crashes.
      Back-patch to 9.4, like commit 846e91e0.
      Before that commit, we used a different linking technique that yielded
      "libpq.dll" in the DLL header.
      
      Commit 53566fc0 worked around this by
      eliminating a call to a function that loads and unloads DLLs internally.
      That commit is no longer necessary for correctness, but its improving
      consistency with the MSVC build remains valid.
      c0e19036
    • Robert Haas's avatar
      Add missing equals signs to pg_recvlogical documentation. · 7f609a10
      Robert Haas authored
      Michael Paquier
      7f609a10
    • Heikki Linnakangas's avatar
      Fix two bugs in tsquery @> operator. · 22926e00
      Heikki Linnakangas authored
      1. The comparison for matching terms used only the CRC to decide if there's
      a match. Two different terms with the same CRC gave a match.
      
      2. It assumed that if the second operand has more terms than the first, it's
      never a match. That assumption is bogus, because there can be duplicate
      terms in either operand.
      
      Rewrite the implementation in a way that doesn't have those bugs.
      
      Backpatch to all supported versions.
      22926e00
    • Bruce Momjian's avatar
      Add variable names to two LWLock C prototypes · a4da35a0
      Bruce Momjian authored
      Previously only the variable types appeared.
      a4da35a0
    • Tom Lane's avatar
      Avoid unportable strftime() behavior in pg_dump/pg_dumpall. · f455fcfd
      Tom Lane authored
      Commit ad5d46a4 thought that we could
      get around the known portability issues of strftime's %Z specifier by
      using %z instead.  However, that idea seems to have been innocent of
      any actual research, as it certainly missed the facts that
      (1) %z is not portable to pre-C99 systems, and
      (2) %z doesn't actually act differently from %Z on Windows anyway.
      
      Per failures on buildfarm member hamerkop.
      
      While at it, centralize the code defining what strftime format we
      want to use in pg_dump; three copies of that string seems a bit much.
      f455fcfd
  11. 26 Oct, 2014 4 commits
    • Tom Lane's avatar
      Fix undersized result buffer in pset_quoted_string(). · 9711fa06
      Tom Lane authored
      The malloc request was 1 byte too small for the worst-case output.
      This seems relatively unlikely to cause any problems in practice,
      as the worst case only occurs if the input string contains no
      characters other than single-quote or newline, and even then
      malloc alignment padding would probably save the day.  But it's
      definitely a bug.
      
      David Rowley
      9711fa06
    • Tom Lane's avatar
      Improve planning of btree index scans using ScalarArrayOpExpr quals. · a4523c5a
      Tom Lane authored
      Since we taught btree to handle ScalarArrayOpExpr quals natively (commit
      9e8da0f7), the planner has always included
      ScalarArrayOpExpr quals in index conditions if possible.  However, if the
      qual is for a non-first index column, this could result in an inferior plan
      because we can no longer take advantage of index ordering (cf. commit
      807a40c5).  It can be better to omit the
      ScalarArrayOpExpr qual from the index condition and let it be done as a
      filter, so that the output doesn't need to get sorted.  Indeed, this is
      true for the query introduced as a test case by the latter commit.
      
      To fix, restructure get_index_paths and build_index_paths so that we
      consider paths both with and without ScalarArrayOpExpr quals in non-first
      index columns.  Redesign the API of build_index_paths so that it reports
      what it found, saving useless second or third calls.
      
      Report and patch by Andrew Gierth (though rather heavily modified by me).
      Back-patch to 9.2 where this code was introduced, since the issue can
      result in significant performance regressions compared to plans produced
      by 9.1 and earlier.
      a4523c5a
    • Peter Eisentraut's avatar
      Fix TAP tests with Perl 5.12 · 17009fb9
      Peter Eisentraut authored
      Perl 5.12 ships with a somewhat broken version of Test::Simple, so skip
      the tests if that is found.
      
      The relevant fix is
      
          0.98  Wed, 23 Feb 2011 14:38:02 +1100
              Bug Fixes
              * subtest() should not fail if $? is non-zero. (Aaron Crane)
      17009fb9
    • Peter Eisentraut's avatar
      Fix TAP tests with Perl 5.8 · 5c3d830e
      Peter Eisentraut authored
      The prove program included in Perl 5.8 does not support the --ext
      option, so don't use that and use wildcards on the command line instead.
      
      Note that the tests will still all be skipped, because, for instance,
      the version of Test::More is too old, but at least the regular
      mechanisms for handling that will apply, instead of failing to call
      prove altogether.
      5c3d830e
  12. 25 Oct, 2014 1 commit