Skip to content
Snippets Groups Projects
  1. Jun 21, 2012
    • Tom Lane's avatar
      Fix memory leak in ARRAY(SELECT ...) subqueries. · 66567ab2
      Tom Lane authored
      Repeated execution of an uncorrelated ARRAY_SUBLINK sub-select (which
      I think can only happen if the sub-select is embedded in a larger,
      correlated subquery) would leak memory for the duration of the query,
      due to not reclaiming the array generated in the previous execution.
      Per bug #6698 from Armando Miraglia.  Diagnosis and fix idea by Heikki,
      patch itself by me.
      
      This has been like this all along, so back-patch to all supported versions.
      66567ab2
  2. Jun 15, 2012
    • Peter Eisentraut's avatar
      Improve reporting of permission errors for array types · 0b847cba
      Peter Eisentraut authored
      Because permissions are assigned to element types, not array types,
      complaining about permission denied on an array type would be
      misleading to users.  So adjust the reporting to refer to the element
      type instead.
      
      In order not to duplicate the required logic in two dozen places,
      refactor the permission denied reporting for types a bit.
      
      pointed out by Yeb Havinga during the review of the type privilege
      feature
      0b847cba
  3. Jun 10, 2012
  4. Jun 07, 2012
  5. Jun 01, 2012
  6. May 31, 2012
    • Tom Lane's avatar
      Force PL and range-type support functions to be owned by a superuser. · ad0009e7
      Tom Lane authored
      We allow non-superusers to create procedural languages (with restrictions)
      and range datatypes.  Previously, the automatically-created support
      functions for these objects ended up owned by the creating user.  This
      represents a rather considerable security hazard, because the owning user
      might be able to alter a support function's definition in such a way as to
      crash the server, inject trojan-horse SQL code, or even execute arbitrary
      C code directly.  It appears that right now the only actually exploitable
      problem is the infinite-recursion bug fixed in the previous patch for
      CVE-2012-2655.  However, it's not hard to imagine that future additions of
      more ALTER FUNCTION capability might unintentionally open up new hazards.
      To forestall future problems, cause these support functions to be owned by
      the bootstrap superuser, not the user creating the parent object.
      ad0009e7
    • Tom Lane's avatar
      Expand the allowed range of timezone offsets to +/-15:59:59 from Greenwich. · cd0ff9c0
      Tom Lane authored
      We used to only allow offsets less than +/-13 hours, then it was +/14,
      then it was +/-15.  That's still not good enough though, as per today's bug
      report from Patric Bechtel.  This time I actually looked through the Olson
      timezone database to find the largest offsets used anywhere.  The winners
      are Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at
      +15:13:42 until 1867.  So we'd better allow offsets less than +/-16 hours.
      
      Given the history, we are way overdue to have some greppable #define
      symbols controlling this, so make some ... and also remove an obsolete
      comment that didn't get fixed the last time.
      
      Back-patch to all supported branches.
      cd0ff9c0
  7. May 30, 2012
    • Heikki Linnakangas's avatar
      Change the way parent pages are tracked during buffered GiST build. · d1996ed5
      Heikki Linnakangas authored
      We used to mimic the way a stack is constructed when descending the tree
      during normal GiST inserts, but that was quite complicated during a buffered
      build. It was also wrong: in GiST, the left-to-right relationships on
      different levels might not match each other, so that when you know the
      parent of a child page, you won't necessarily find the parent of the page to
      the right of the child page by following the rightlinks at the parent level.
      This sometimes led to "could not re-find parent" errors while building a
      GiST index.
      
      We now use a simple hash table to track the parent of every internal page.
      Whenever a page is split, and downlinks are moved from one page to another,
      we update the hash table accordingly. This is also better for performance
      than the old method, as we never need to move right to re-find the parent
      page, which could take a significant amount of time for buffers that were
      created much earlier in the index build.
      d1996ed5
  8. May 18, 2012
    • Heikki Linnakangas's avatar
      Fix bug in gistRelocateBuildBuffersOnSplit(). · 1d27dcf5
      Heikki Linnakangas authored
      When we create a temporary copy of the old node buffer, in stack, we mustn't
      leak that into any of the long-lived data structures. Before this patch,
      when we called gistPopItupFromNodeBuffer(), it got added to the array of
      "loaded buffers". After gistRelocateBuildBuffersOnSplit() exits, the
      pointer added to the loaded buffers array points to garbage. Often that goes
      unnotied, because when we go through the array of loaded buffers to unload
      them, buffers with a NULL pageBuffer are ignored, which can often happen by
      accident even if the pointer points to garbage.
      
      This patch fixes that by marking the temporary copy in stack explicitly as
      temporary, and refrain from adding buffers marked as temporary to the array
      of loaded buffers.
      
      While we're at it, initialize nodeBuffer->pageBlocknum to InvalidBlockNumber
      and improve comments a bit. This isn't strictly necessary, but makes
      debugging easier.
      1d27dcf5
  9. May 16, 2012
  10. May 15, 2012
    • Tom Lane's avatar
      Put back AC_REQUIRE([AC_STRUCT_TM]). · f667747b
      Tom Lane authored
      The BSD-ish members of the buildfarm all seem to think removing this
      was a bad idea.  It looks to me like it resulted in omitting the system
      header inclusion necessary to detect the fields of struct tm correctly.
      f667747b
  11. May 14, 2012
  12. May 11, 2012
  13. May 10, 2012
    • Heikki Linnakangas's avatar
      Fix outdated comment. · 60a3dffb
      Heikki Linnakangas authored
      Multi-insert records observe XLOG_HEAP_INIT_PAGE flag too, as Andres Freund
      pointed out.
      60a3dffb
    • Tom Lane's avatar
      Improve control logic for bgwriter hibernation mode. · 6308ba05
      Tom Lane authored
      Commit 6d90eaaa added a hibernation mode
      to the bgwriter to reduce the server's idle-power consumption.  However,
      its interaction with the detailed behavior of BgBufferSync's feedback
      control loop wasn't very well thought out.  That control loop depends
      primarily on the rate of buffer allocation, not the rate of buffer
      dirtying, so the hibernation mode has to be designed to operate only when
      no new buffer allocations are happening.  Also, the check for whether the
      system is effectively idle was not quite right and would fail to detect
      a constant low level of activity, thus allowing the bgwriter to go into
      hibernation mode in a way that would let the cycle time vary quite a bit,
      possibly further confusing the feedback loop.  To fix, move the wakeup
      support from MarkBufferDirty and SetBufferCommitInfoNeedsSave into
      StrategyGetBuffer, and prevent the bgwriter from entering hibernation mode
      unless no buffer allocations have happened recently.
      
      In addition, fix the delaying logic to remove the problem of possibly not
      responding to signals promptly, which was basically caused by trying to use
      the process latch's is_set flag for multiple purposes.  I can't prove it
      but I'm suspicious that that hack was responsible for the intermittent
      "postmaster does not shut down" failures we've been seeing in the buildfarm
      lately.  In any case it did nothing to improve the readability or
      robustness of the code.
      
      In passing, express the hibernation sleep time as a multiplier on
      BgWriterDelay, not a constant.  I'm not sure whether there's any value in
      exposing the longer sleep time as an independently configurable setting,
      but we can at least make it act like this for little extra code.
      6308ba05
  14. May 09, 2012
    • Simon Riggs's avatar
    • Simon Riggs's avatar
      bbd3ec9d
    • Tom Lane's avatar
      Fix an issue in recent walwriter hibernation patch. · acd4c7d5
      Tom Lane authored
      Users of asynchronous-commit mode expect there to be a guaranteed maximum
      delay before an async commit's WAL records get flushed to disk.  The
      original version of the walwriter hibernation patch broke that.  Add an
      extra shared-memory flag to allow async commits to kick the walwriter out
      of hibernation mode, without adding any noticeable overhead in cases where
      no action is needed.
      acd4c7d5
    • Tom Lane's avatar
      Reduce idle power consumption of walwriter and checkpointer processes. · 5461564a
      Tom Lane authored
      This patch modifies the walwriter process so that, when it has not found
      anything useful to do for many consecutive wakeup cycles, it extends its
      sleep time to reduce the server's idle power consumption.  It reverts to
      normal as soon as it's done any successful flushes.  It's still true that
      during any async commit, backends check for completed, unflushed pages of
      WAL and signal the walwriter if there are any; so that in practice the
      walwriter can get awakened and returned to normal operation sooner than the
      sleep time might suggest.
      
      Also, improve the checkpointer so that it uses a latch and a computed delay
      time to not wake up at all except when it has something to do, replacing a
      previous hardcoded 0.5 sec wakeup cycle.  This also is primarily useful for
      reducing the server's power consumption when idle.
      
      In passing, get rid of the dedicated latch for signaling the walwriter in
      favor of using its procLatch, since that comports better with possible
      generic signal handlers using that latch.  Also, fix a pre-existing bug
      with failure to save/restore errno in walwriter's signal handlers.
      
      Peter Geoghegan, somewhat simplified by Tom
      5461564a
  15. May 07, 2012
  16. May 04, 2012
    • Tom Lane's avatar
      Overdue code review for transaction-level advisory locks patch. · 71b9549d
      Tom Lane authored
      Commit 62c7bd31 had assorted problems, most
      visibly that it broke PREPARE TRANSACTION in the presence of session-level
      advisory locks (which should be ignored by PREPARE), as per a recent
      complaint from Stephen Rees.  More abstractly, the patch made the
      LockMethodData.transactional flag not merely useless but outright
      dangerous, because in point of fact that flag no longer tells you anything
      at all about whether a lock is held transactionally.  This fix therefore
      removes that flag altogether.  We now rely entirely on the convention
      already in use in lock.c that transactional lock holds must be owned by
      some ResourceOwner, while session holds are never so owned.  Setting the
      locallock struct's owner link to NULL thus denotes a session hold, and
      there is no redundant marker for that.
      
      PREPARE TRANSACTION now works again when there are session-level advisory
      locks, and it is also able to transfer transactional advisory locks to the
      prepared transaction, but for implementation reasons it throws an error if
      we hold both types of lock on a single lockable object.  Perhaps it will be
      worth improving that someday.
      
      Assorted other minor cleanup and documentation editing, as well.
      
      Back-patch to 9.1, except that in the 9.1 branch I did not remove the
      LockMethodData.transactional flag for fear of causing an ABI break for
      any external code that might be examining those structs.
      71b9549d
  17. May 03, 2012
  18. May 02, 2012
  19. May 01, 2012
    • Peter Eisentraut's avatar
      Remove dead ports · f2f9439f
      Peter Eisentraut authored
      Remove the following ports:
      
      - dgux
      - nextstep
      - sunos4
      - svr4
      - ultrix4
      - univel
      
      These are obsolete and not worth rescuing.  In most cases, there is
      circumstantial evidence that they wouldn't work anymore anyway.
      f2f9439f
  20. Apr 30, 2012
    • Tom Lane's avatar
      Converge all SQL-level statistics timing values to float8 milliseconds. · 809e7e21
      Tom Lane authored
      This patch adjusts the core statistics views to match the decision already
      taken for pg_stat_statements, that values representing elapsed time should
      be represented as float8 and measured in milliseconds.  By using float8,
      we are no longer tied to a specific maximum precision of timing data.
      (Internally, it's still microseconds, but we could now change that without
      needing changes at the SQL level.)
      
      The columns affected are
      pg_stat_bgwriter.checkpoint_write_time
      pg_stat_bgwriter.checkpoint_sync_time
      pg_stat_database.blk_read_time
      pg_stat_database.blk_write_time
      pg_stat_user_functions.total_time
      pg_stat_user_functions.self_time
      pg_stat_xact_user_functions.total_time
      pg_stat_xact_user_functions.self_time
      
      The first four of these are new in 9.2, so there is no compatibility issue
      from changing them.  The others require a release note comment that they
      are now double precision (and can show a fractional part) rather than
      bigint as before; also their underlying statistics functions now match
      the column definitions, instead of returning bigint microseconds.
      809e7e21
    • Peter Eisentraut's avatar
      Mark ReThrowError() with attribute noreturn · 26471a51
      Peter Eisentraut authored
      All related functions were already so marked.
      26471a51
    • Tom Lane's avatar
      Rename I/O timing statistics columns to blk_read_time and blk_write_time. · 1dd89ead
      Tom Lane authored
      This seems more consistent with the pre-existing choices for names of
      other statistics columns.  Rename assorted internal identifiers to match.
      1dd89ead
  21. Apr 29, 2012
Loading