1. 22 Mar, 2013 4 commits
    • Simon Riggs's avatar
      Allow I/O reliability checks using 16-bit checksums · 96ef3b8f
      Simon Riggs authored
      Checksums are set immediately prior to flush out of shared buffers
      and checked when pages are read in again. Hint bit setting will
      require full page write when block is dirtied, which causes various
      infrastructure changes. Extensive comments, docs and README.
      
      WARNING message thrown if checksum fails on non-all zeroes page;
      ERROR thrown but can be disabled with ignore_checksum_failure = on.
      
      Feature enabled by an initdb option, since transition from option off
      to option on is long and complex and has not yet been implemented.
      Default is not to use checksums.
      
      Checksum used is WAL CRC-32 truncated to 16-bits.
      
      Simon Riggs, Jeff Davis, Greg Smith
      Wide input and assistance from many community members. Thank you.
      96ef3b8f
    • Andrew Dunstan's avatar
      Silence compiler warnings about unused values. · e4a05c75
      Andrew Dunstan authored
      Per gripe from Kevin Grittner.
      e4a05c75
    • Simon Riggs's avatar
      Change commit_delay to be SUSET for 9.3+ · 13fe298c
      Simon Riggs authored
      Prior to 9.3 the commit_delay affected only the current user,
      whereas now only the group leader waits while holding the
      WALWriteLock. Deliberate or accidental settings to a poor
      value could seriously degrade performance for all users.
      Privileges may be delegated by SECURITY DEFINER functions
      for anyone that needs per-user settings in real situations.
      Request for change from Peter Geoghegan
      13fe298c
    • Tom Lane's avatar
      Avoid retrieving dummy NULL columns in postgres_fdw. · e690b951
      Tom Lane authored
      This should provide some marginal overall savings, since it surely takes
      many more cycles for the remote server to deal with the NULL columns than
      it takes for postgres_fdw not to emit them.  But really the reason is to
      keep the emitted queries from looking quite so silly ...
      e690b951
  2. 21 Mar, 2013 3 commits
    • Tom Lane's avatar
      Redo postgres_fdw's planner code so it can handle parameterized paths. · 9cbc4b80
      Tom Lane authored
      I wasn't going to ship this without having at least some example of how
      to do that.  This version isn't terribly bright; in particular it won't
      consider any combinations of multiple join clauses.  Given the cost of
      executing a remote EXPLAIN, I'm not sure we want to be very aggressive
      about doing that, anyway.
      
      In support of this, refactor generate_implied_equalities_for_indexcol
      so that it can be used to extract equivalence clauses that aren't
      necessarily tied to an index.
      9cbc4b80
    • Kevin Grittner's avatar
    • Heikki Linnakangas's avatar
      Fix "element <@ range" cost estimation. · f897c474
      Heikki Linnakangas authored
      The statistics-based cost estimation patch for range types broke that, by
      incorrectly assuming that the left operand of all range oeprators is a
      range. That lead to a "type x is not a range type" error. Because it took so
      long for anyone to notice, add a regression test for that case.
      
      We still don't do proper statistics-based cost estimation for that, so you
      just get a default constant estimate. We should look into implementing that,
      but this patch at least fixes the regression.
      
      Spotted by Tom Lane, when testing query from Josh Berkus.
      f897c474
  3. 20 Mar, 2013 2 commits
    • Alvaro Herrera's avatar
      Allow extracting machine-readable object identity · f8348ea3
      Alvaro Herrera authored
      Introduce pg_identify_object(oid,oid,int4), which is similar in spirit
      to pg_describe_object but instead produces a row of machine-readable
      information to uniquely identify the given object, without resorting to
      OIDs or other internal representation.  This is intended to be used in
      the event trigger implementation, to report objects being operated on;
      but it has usefulness of its own.
      
      Catalog version bumped because of the new function.
      f8348ea3
    • Tom Lane's avatar
      Bump up timeout delays some more in timeouts isolation test. · a7921f71
      Tom Lane authored
      The buildfarm members using -DCLOBBER_CACHE_ALWAYS still don't like this
      test.  Some experimentation shows that on my machine, isolationtester's
      query to check for "waiting" state takes 2 to 2.5 seconds to bind+execute
      under -DCLOBBER_CACHE_ALWAYS.  Set the timeouts to 5 seconds to leave some
      headroom for possibly-slower buildfarm critters.
      
      Really we ought to fix the "waiting" query, which is not only horridly
      slow but outright wrong in detail; and then maybe we can back off these
      timeouts.  But right now I'm just trying to get the buildfarm green again.
      a7921f71
  4. 19 Mar, 2013 3 commits
  5. 18 Mar, 2013 8 commits
    • Simon Riggs's avatar
      Add reliability docs about storage/memory corruptions. · 2266db39
      Simon Riggs authored
      Add section to the Reliability section about what is and is not protected for
      various file types.
      Further edits welcome.
      
      Designed to allow 1-2 line change when/if checksums are committed.
      
      Inspired by docs written by Jeff Davis, though completely different from his
      patch.
      2266db39
    • Tom Lane's avatar
      Improve documentation of EXTRACT(WEEK). · e39feb10
      Tom Lane authored
      The docs showed that early-January dates can be considered part of the
      previous year for week-counting purposes, but failed to say explicitly
      that late-December dates can also be considered part of the next year.
      Fix that, and add a cross-reference to the "isoyear" field.  Per bug
      #7967 from Pawel Kobylak.
      e39feb10
    • Simon Riggs's avatar
      e016b724
    • Simon Riggs's avatar
      ef04cb74
    • Simon Riggs's avatar
      Remove PageSetTLI and rename pd_tli to pd_checksum · bb7cc262
      Simon Riggs authored
      Remove use of PageSetTLI() from all page manipulation functions
      and adjust README to indicate change in the way we make changes
      to pages. Repurpose those bytes into the pd_checksum field and
      explain how that works in comments about page header.
      
      Refactoring ahead of actual feature patch which would make use
      of the checksum field, arriving later.
      
      Jeff Davis, with comments and doc changes by Simon Riggs
      Direction suggested by Robert Haas; many others providing
      review comments.
      bb7cc262
    • Tom Lane's avatar
      Increase timeout delays in new timeouts isolation test. · 4c855750
      Tom Lane authored
      Buildfarm member friarbird doesn't like this test as-committed, evidently
      because it's so slow that the test framework doesn't reliably notice that
      the backend is waiting before the timeout goes off.  (This is not totally
      surprising, since friarbird builds with -DCLOBBER_CACHE_ALWAYS.)  Increase
      the timeout delay from 1 second to 2 in hopes of resolving that problem.
      4c855750
    • Robert Haas's avatar
      Extend object-access hook machinery to support post-alter events. · 05f3f9c7
      Robert Haas authored
      This also slightly widens the scope of what we support in terms of
      post-create events.
      
      KaiGai Kohei, with a few changes, mostly to the comments, by me
      05f3f9c7
    • Tom Lane's avatar
      Improve signal-handler lockout mechanism in timeout.c. · 6ac7facd
      Tom Lane authored
      Rather than doing a fairly-expensive setitimer() call to prevent interrupts
      from happening, let's just invent a simple boolean flag that the signal
      handler is required to check.  This is not only faster but considerably
      more robust than before, since the previous code effectively assumed that
      only ITIMER_REAL events would ever fire the SIGALRM handler, which is
      obviously something that can be broken easily by third-party code.
      
      Zoltán Böszörményi and Tom Lane
      6ac7facd
  6. 17 Mar, 2013 9 commits
    • Tom Lane's avatar
      Use pqsignal() in contrib programs rather than calling signal(2) directly. · 3c07fbf4
      Tom Lane authored
      The semantics of signal(2) are more variable than one could wish; in
      particular, on strict-POSIX platforms the signal handler will be reset
      to SIG_DFL when the signal is delivered.  This demonstrably breaks
      pg_test_fsync's use of SIGALRM.  The other changes I made are not
      absolutely necessary today, because the called handlers all exit the
      program anyway.  But it seems like a good general practice to use
      pqsignal() exclusively in Postgres code, now that we have it available
      everywhere.
      3c07fbf4
    • Tom Lane's avatar
      Re-include pqsignal() in libpq. · b1fae823
      Tom Lane authored
      We need this in non-ENABLE_THREAD_SAFETY builds, and also to satisfy
      the exports.txt entry; while it might be a good idea to remove the
      latter, I'm hesitant to do so except in the context of an intentional
      ABI break.  At least we don't have a separately maintained source file
      for it anymore.
      b1fae823
    • Tom Lane's avatar
      initdb needs pqsignal() even on Windows. · e2a203a1
      Tom Lane authored
      I had thought we weren't using this version of pqsignal() at all on
      Windows, but that's wrong --- initdb is using it (and coping with the
      POSIX-ish semantics of bare signal() :-().  So allow the file to be
      built in WIN32+FRONTEND case, and add it to the MSVC build logic.
      e2a203a1
    • Tom Lane's avatar
      Fix inclusions in pgbench.c. · 8c41cb69
      Tom Lane authored
      Apparently this was depending on pqsignal.h for <signal.h>.
      Not sure why I didn't see the failure on my other machine.
      8c41cb69
    • Tom Lane's avatar
      Fix inclusions in pg_receivexlog.c. · c68b5eff
      Tom Lane authored
      Apparently this was depending on pqsignal.h for <signal.h>.
      Not sure why I didn't see the failure on my other machine.
      c68b5eff
    • Tom Lane's avatar
      Move pqsignal() to libpgport. · da5aeccf
      Tom Lane authored
      We had two copies of this function in the backend and libpq, which was
      already pretty bogus, but it turns out that we need it in some other
      programs that don't use libpq (such as pg_test_fsync).  So put it where
      it probably should have been all along.  The signal-mask-initialization
      support in src/backend/libpq/pqsignal.c stays where it is, though, since
      we only need that in the backend.
      da5aeccf
    • Tom Lane's avatar
      Add lock_timeout configuration parameter. · d43837d0
      Tom Lane authored
      This GUC allows limiting the time spent waiting to acquire any one
      heavyweight lock.
      
      In support of this, improve the recently-added timeout infrastructure
      to permit efficiently enabling or disabling multiple timeouts at once.
      That reduces the performance hit from turning on lock_timeout, though
      it's still not zero.
      
      Zoltán Böszörményi, reviewed by Tom Lane,
      Stephen Frost, and Hari Babu
      d43837d0
    • Peter Eisentraut's avatar
      d2bef5f7
    • Peter Eisentraut's avatar
      ea1aee88
  7. 15 Mar, 2013 3 commits
    • Tom Lane's avatar
      Improve the documentation about commit_delay. · 70ec2f8f
      Tom Lane authored
      Clarify the docs explaining what commit_delay does, and add a
      recommendation about a useful value for it, namely half of the single-page
      fsync time reported by pg_test_fsync.  This is informed by testing of
      the new-in-9.3 implementation of commit_delay; in prior versions it
      was far harder to arrive at a useful setting.
      
      In passing, do some wordsmithing and markup-fixing in the same general
      area.
      
      Also, change pg_test_fsync's default time-per-test from 2 seconds to 5.
      The old value was about the minimum at which the results could be taken
      seriously at all, and so seems a tad optimistic as a default.
      
      Peter Geoghegan, reviewed by Noah Misch; some additional editing by me
      70ec2f8f
    • Tom Lane's avatar
      Improve error reporting in code that checks for buffer refcount leaks. · dcafdbcd
      Tom Lane authored
      Formerly we just Assert'ed that each refcount was zero, which was quick
      and easy but failed to provide a good overview of what was wrong.
      Change the code so that we'll call PrintBufferLeakWarning() for each
      buffer with a nonzero refcount, and then Assert at the end of the loop.
      This costs nothing in runtime and might ease diagnosis of some bugs.
      
      Greg Smith, reviewed by Satoshi Nagayasu, further tweaked by me
      dcafdbcd
    • Tom Lane's avatar
      Extend format() to handle field width and left/right alignment. · 73e7025b
      Tom Lane authored
      This change adds some more standard sprintf() functionality to format().
      
      Pavel Stehule, reviewed by Dean Rasheed and Kyotaro Horiguchi
      73e7025b
  8. 14 Mar, 2013 8 commits
    • Tom Lane's avatar
      Avoid inserting no-op Limit plan nodes. · 1a1832eb
      Tom Lane authored
      This was discussed in connection with the patch to avoid inserting no-op
      Result nodes, but not actually implemented therein.
      1a1832eb
    • Kevin Grittner's avatar
      Revert unnecessary change in MV call to checkRuleResultList(). · fb60e729
      Kevin Grittner authored
      Due to a misreading of the function's comment block, there was an
      unneeded change to a call in rewriteDefine.c.  There is, in fact
      no reason to pass false for a MV; it should be true just like a
      view.
      
      Fixes issue pointed out by Tom Lane
      fb60e729
    • Kevin Grittner's avatar
      Add regression test for MV join to view. · 8d7ff13e
      Kevin Grittner authored
      This would have caught a bug in the initial patch, and seems like
      a good thing to test going forward.
      
      Per bug report by Erik Rijkers and fix by Tom Lane
      8d7ff13e
    • Heikki Linnakangas's avatar
      Also update psqlscan.l with the UESCAPE error rule changes. · f7559c01
      Heikki Linnakangas authored
      Even though this patch had no user-visible difference, better keep the code
      in psqlscan.l sync with the backend lexer. And of course it's nice to shrink
      the psql binary, too. Ecpg's version of the lexer doesn't have the error
      rule, it doesn't try to avoid backing up, so it doesn't need to be modified.
      
      As reminded by Tom Lane
      f7559c01
    • Tom Lane's avatar
      Minor fixes for hstore_to_json_loose(). · c2754991
      Tom Lane authored
      Fix unportable use of isdigit(), get rid of useless calculations.
      c2754991
    • Tom Lane's avatar
      Avoid inserting Result nodes that only compute identity projections. · 4387cf95
      Tom Lane authored
      The planner sometimes inserts Result nodes to perform column projections
      (ie, arbitrary scalar calculations) above plan nodes that lack projection
      logic of their own.  However, we did that even if the lower plan node was
      in fact producing the required column set already; which is a pretty common
      case given the popularity of "SELECT * FROM ...".  Measurements show that
      the useless plan node adds non-negligible overhead, especially when there
      are many columns in the result.  So add a check to avoid inserting a Result
      node unless there's something useful for it to do.
      
      There are a couple of remaining places where unnecessary Result nodes
      could get inserted, but they are (a) much less performance-critical,
      and (b) coded in such a way that it's hard to avoid inserting a Result,
      because the desired tlist is changed on-the-fly in subsequent logic.
      We'll leave those alone for now.
      
      Kyotaro Horiguchi; reviewed and further hacked on by Amit Kapila and
      Tom Lane.
      4387cf95
    • Heikki Linnakangas's avatar
      Change the way UESCAPE is lexed, to reduce the size of the flex tables. · a5ff502f
      Heikki Linnakangas authored
      The error rule used to avoid backtracking with the U&'...' UESCAPE 'x'
      syntax bloated the flex tables, so refactor that. This patch makes the error
      rule shorter, by introducing a new exclusive flex state that's entered after
      parsing U&'...'. This shrinks the postgres binary by about 220kB.
      a5ff502f
    • Heikki Linnakangas's avatar
      Add cost estimation of range @> and <@ operators. · 59d0bf9d
      Heikki Linnakangas authored
      The estimates are based on the existing lower bound histogram, and a new
      histogram of range lengths.
      
      Bump catversion, because the range length histogram now needs to be present
      in statistic slot kind 6, or you get an error on @> and <@ queries. (A
      re-ANALYZE would be enough to fix that, though)
      
      Alexander Korotkov, with some refactoring by me.
      59d0bf9d