1. 09 Feb, 2014 4 commits
  2. 07 Feb, 2014 4 commits
    • Heikki Linnakangas's avatar
      Initialize the entryRes array between each call to triConsistent. · 6aa2bdf6
      Heikki Linnakangas authored
      The shimTriConstistentFn, which calls the opclass's consistent function with
      all combinations of TRUE/FALSE for any MAYBE argument, modifies the entryRes
      array passed by the caller. Change startScanKey to re-initialize it between
      each call to accommodate that.
      
      It's actually a bad habit by shimTriConsistentFn to modify its argument. But
      the only caller that doesn't already re-initialize the entryRes array was
      startScanKey, and it's easy for startScanKey to do so. Add a comment to
      shimTriConsistentFn about that.
      
      Note: this does not give a free pass to opclass-provided consistent
      functions to modify the entryRes argument; shimTriConsistent assumes that
      they don't, even though it does it itself.
      
      While at it, refactor startScanKey to allocate the requiredEntries and
      additionalEntries after it knows exactly how large they need to be. Saves a
      little bit of memory, and looks nicer anyway.
      
      Per complaint by Tom Lane, buildfarm and the pg_trgm regression test.
      6aa2bdf6
    • Heikki Linnakangas's avatar
      Speed up "rare & frequent" type GIN queries. · dbc649fd
      Heikki Linnakangas authored
      If you have a GIN query like "rare & frequent", we currently fetch all the
      items that match either rare or frequent, call the consistent function for
      each item, and let the consistent function filter out items that only match
      one of the terms. However, if we can deduce that "rare" must be present for
      the overall qual to be true, we can scan all the rare items, and for each
      rare item, skip over to the next frequent item with the same or greater TID.
      That greatly speeds up "rare & frequent" type queries.
      
      To implement that, introduce the concept of a tri-state consistent function,
      where the 3rd value is MAYBE, indicating that we don't know if that term is
      present. Operator classes only provide a boolean consistent function, so we
      simulate the tri-state consistent function by calling the boolean function
      several times, with the MAYBE arguments set to all combinations of TRUE and
      FALSE. Testing all combinations is only feasible for a small number of MAYBE
      arguments, but it is envisioned that we'll provide a way for operator
      classes to provide a native tri-state consistent function, which can be much
      more efficient. But that is not included in this patch.
      
      We were already using that trick to for lossy pages, calling the consistent
      function with the lossy entry set to TRUE and FALSE. Now that we have the
      tri-state consistent function, use it for lossy pages too.
      
      Alexander Korotkov, with fair amount of refactoring by me.
      dbc649fd
    • Heikki Linnakangas's avatar
      Fix thinko in comment. · e001030c
      Heikki Linnakangas authored
      Amit Langote
      e001030c
    • Tom Lane's avatar
      In RelationClearRelation, postpone cache reload if !IsTransactionState(). · 8de3e410
      Tom Lane authored
      We may process relcache flush requests during transaction startup or
      shutdown.  In general it's not terribly safe to do catalog access at those
      times, so the code's habit of trying to immediately revalidate unflushable
      relcache entries is risky.  Although there are no field trouble reports
      that are positively traceable to this, we have been able to demonstrate
      failure of the assertions recently added in RelationIdGetRelation() and
      SearchCatCache().  On the other hand, it seems safe to just postpone
      revalidation of the cache entry until we're inside a valid transaction.
      The one case where this is questionable is where we're exiting a
      subtransaction and the outer transaction is holding the relcache entry open
      --- but if we made any significant changes to the rel inside such a
      subtransaction, we've got problems anyway.  There are mechanisms in place
      to prevent that (to wit, locks for cross-session cases and
      CheckTableNotInUse() for intra-session cases), so let's trust to those
      mechanisms to keep us out of trouble.
      8de3e410
  3. 06 Feb, 2014 4 commits
  4. 05 Feb, 2014 3 commits
    • Tom Lane's avatar
      Remove unnecessary relcache flushes after changing btree metapages. · ac8bc3b6
      Tom Lane authored
      These flushes were added in my commit d2896a9e, which added the btree
      logic that keeps a cached copy of the index metapage data in index relcache
      entries.  The idea was to ensure that other backends would promptly update
      their cached copies after a change.  However, this is not really necessary,
      since _bt_getroot() has adequate defenses against believing a stale root
      page link, and _bt_getrootheight() doesn't have to be 100% right.
      Moreover, if it were necessary, a relcache flush would be an unreliable way
      to do it, since the sinval mechanism believes that relcache flush requests
      represent transactional updates, and therefore discards them on transaction
      rollback.  Therefore, we might as well drop these flush requests and save
      the time to rebuild the whole relcache entry after a metapage change.
      
      If we ever try to support in-place truncation of btree indexes, it might
      be necessary to revisit this issue so that _bt_getroot() can't get caught
      by trying to follow a metapage link to a page that no longer exists.
      A possible solution to that is to make use of an smgr, rather than
      relcache, inval request to force other backends to discard their cached
      metapages.  But for the moment this is not worth pursuing.
      ac8bc3b6
    • Robert Haas's avatar
      Minor improvements to replication slot documentation. · 14aa601f
      Robert Haas authored
      Fix a thinko pointed out by Jeff Davis, and convert a couple of other
      references into links.
      14aa601f
    • Peter Eisentraut's avatar
      PL/Perl: Fix compiler warning · 4e182361
      Peter Eisentraut authored
      The code was assigning a (Datum) 0 to a void pointer.  That creates a
      warning from clang 3.4.  It was probably a thinko to begin with.
      4e182361
  5. 04 Feb, 2014 4 commits
    • Tom Lane's avatar
      Improve connection-failure error handling in contrib/postgres_fdw. · 00d4f2af
      Tom Lane authored
      postgres_fdw tended to say "unknown error" if it tried to execute a command
      on an already-dead connection, because some paths in libpq just return a
      null PGresult for such cases.  Out-of-memory might result in that, too.
      To fix, pass the PGconn to pgfdw_report_error, and look at its
      PQerrorMessage() string if we can't get anything out of the PGresult.
      
      Also, fix the transaction-exit logic to reliably drop a dead connection.
      It was attempting to do that already, but it assumed that only connection
      cache entries with xact_depth > 0 needed to be examined.  The folly in that
      is that if we fail while issuing START TRANSACTION, we'll not have bumped
      xact_depth.  (At least for the case I was testing, this fix masks the
      other problem; but it still seems like a good idea to have the PGconn
      fallback logic.)
      
      Per investigation of bug #9087 from Craig Lucas.  Backpatch to 9.3 where
      this code was introduced.
      00d4f2af
    • Fujii Masao's avatar
      Fix comparison of an array of characters with zero to compare with '\0' instead. · 489e6ac5
      Fujii Masao authored
      Report from Andres Freund.
      489e6ac5
    • Robert Haas's avatar
      Rephrase text to avoid links in regress.sgml · c1fe08eb
      Robert Haas authored
      Otherwise, the standalone regress_README build gets unhappy.
      c1fe08eb
    • Tom Lane's avatar
      Fix lexing of U& sequences just before EOF. · 0c2338ab
      Tom Lane authored
      Commit a5ff502f was a brick shy of a load
      in the backend lexer too, not just psql.  Per further testing of bug #9068.
      
      In passing, improve related comments.
      0c2338ab
  6. 03 Feb, 2014 5 commits
  7. 02 Feb, 2014 6 commits
  8. 01 Feb, 2014 10 commits
    • Tom Lane's avatar
      Fix some wide-character bugs in the text-search parser. · 082c0dfa
      Tom Lane authored
      In p_isdigit and other character class test functions generated by the
      p_iswhat macro, the code path for non-C locales with multibyte encodings
      contained a bogus pointer cast that would accidentally fail to malfunction
      if types wchar_t and wint_t have the same width.  Apparently that is true
      on most platforms, but not on recent Cygwin releases.  Remove the cast,
      as it seems completely unnecessary (I think it arose from a false analogy
      to the need to cast to unsigned char when dealing with the <ctype.h>
      functions).  Per bug #8970 from Marco Atzeri.
      
      In the same functions, the code path for C locale with a multibyte encoding
      simply ANDed each wide character with 0xFF before passing it to the
      corresponding <ctype.h> function.  This could result in false positive
      answers for some non-ASCII characters, so use a range test instead.
      Noted by me while investigating Marco's complaint.
      
      Also, remove some useless though not actually buggy maskings and casts
      in the hand-coded p_isalnum and p_isalpha functions, which evidently
      got tested a bit more carefully than the macro-generated functions.
      082c0dfa
    • Andrew Dunstan's avatar
      fix whitespace · c8158a2e
      Andrew Dunstan authored
      c8158a2e
    • Tom Lane's avatar
      Fix some more bugs in signal handlers and process shutdown logic. · 214c7a4f
      Tom Lane authored
      WalSndKill was doing things exactly backwards: it should first clear
      MyWalSnd (to stop signal handlers from touching MyWalSnd->latch),
      then disown the latch, and only then mark the WalSnd struct unused by
      clearing its pid field.
      
      Also, WalRcvSigUsr1Handler and worker_spi_sighup failed to preserve
      errno, which is surely a requirement for any signal handler.
      
      Per discussion of recent buildfarm failures.  Back-patch as far
      as the relevant code exists.
      214c7a4f
    • Andrew Dunstan's avatar
      Don't use deprecated dllwrap on Cygwin. · 7e1531a4
      Andrew Dunstan authored
      The preferred method is to use "cc -shared", and this allows binaries
      to be rebased if required, unlike dllwrap.
      
      Backpatch to 9.0 where we have buildfarm coverage.
      
      There are still some issues with Cygwin, especially modern Cygwin, but
      this helps us get closer to good support.
      
      Marco Atzeri.
      7e1531a4
    • Andrew Dunstan's avatar
      Copy the libpq DLL to the bin directory on Mingw and Cygwin. · d587298b
      Andrew Dunstan authored
      This has long been done by the MSVC build system, and has caused
      confusion in the past when programs like psql have failed to start
      because they can't find the DLL. If it's in the same directory as it now
      will be they will find it.
      
      Backpatch to all live branches.
      d587298b
    • Bruce Momjian's avatar
      arrays: tighten checks for multi-dimensional input · d0ee9379
      Bruce Momjian authored
      Previously an input array string that started with a single-element
      array dimension would then later accept a multi-dimensional segment.
      
      BACKWARD INCOMPATIBILITY
      d0ee9379
    • Robert Haas's avatar
      Introduce replication slots. · 858ec118
      Robert Haas authored
      Replication slots are a crash-safe data structure which can be created
      on either a master or a standby to prevent premature removal of
      write-ahead log segments needed by a standby, as well as (with
      hot_standby_feedback=on) pruning of tuples whose removal would cause
      replication conflicts.  Slots have some advantages over existing
      techniques, as explained in the documentation.
      
      In a few places, we refer to the type of replication slots introduced
      by this patch as "physical" slots, because forthcoming patches for
      logical decoding will also have slots, but with somewhat different
      properties.
      
      Andres Freund and Robert Haas
      858ec118
    • Bruce Momjian's avatar
      docs: mention 'g' is not in the regex embedded options table · 5bdef38b
      Bruce Momjian authored
      Mentioned in substring() and regexp_replace() sections.
      5bdef38b
    • Bruce Momjian's avatar
      pg_restore: make help output plural for multi-enabled options · 5168c769
      Bruce Momjian authored
      per report from Josh Kupershmidt
      5168c769
    • Robert Haas's avatar
      Clear MyProc and MyProcSignalState before they become invalid. · d1981719
      Robert Haas authored
      Evidence from buildfarm member crake suggests that the new test_shm_mq
      module is routinely crashing the server due to the arrival of a SIGUSR1
      after the shared memory segment has been unmapped.  Although processes
      using the new dynamic background worker facilities are more likely to
      receive a SIGUSR1 around this time, the problem is also possible on older
      branches, so I'm back-patching the parts of this change that apply to
      older branches as far as they apply.
      
      It's already generally the case that code checks whether these pointers
      are NULL before deferencing them, so the important thing is mostly to
      make sure that they do get set to NULL before they become invalid.  But
      in master, there's one case in procsignal_sigusr1_handler that lacks a
      NULL guard, so add that.
      
      Patch by me; review by Tom Lane.
      d1981719