1. 23 3月, 2011 1 次提交
    • T
      Avoid potential deadlock in InitCatCachePhase2(). · cf735470
      Tom Lane 提交于
      Opening a catcache's index could require reading from that cache's own
      catalog, which of course would acquire AccessShareLock on the catalog.
      So the original coding here risks locking index before heap, which could
      deadlock against another backend trying to get exclusive locks in the
      normal order.  Because InitCatCachePhase2 is only called when a backend
      has to start up without a relcache init file, the deadlock was seldom seen
      in the field.  (And by the same token, there's no need to worry about any
      performance disadvantage; so not much point in trying to distinguish
      exactly which catalogs have the risk.)
      
      Bug report, diagnosis, and patch by Nikhil Sontakke.  Additional commentary
      by me.  Back-patch to all supported branches.
      cf735470
  2. 17 3月, 2011 2 次提交
  3. 12 3月, 2011 2 次提交
  4. 22 2月, 2011 1 次提交
    • T
      Fix dangling-pointer problem in before-row update trigger processing. · e476eedd
      Tom Lane 提交于
      ExecUpdate checked for whether ExecBRUpdateTriggers had returned a new
      tuple value by seeing if the returned tuple was pointer-equal to the old
      one.  But the "old one" was in estate->es_junkFilter's result slot, which
      would be scribbled on if we had done an EvalPlanQual update in response to
      a concurrent update of the target tuple; therefore we were comparing a
      dangling pointer to a live one.  Given the right set of circumstances we
      could get a false match, resulting in not forcing the tuple to be stored in
      the slot we thought it was stored in.  In the case reported by Maxim Boguk
      in bug #5798, this led to "cannot extract system attribute from virtual
      tuple" failures when trying to do "RETURNING ctid".  I believe there is a
      very-low-probability chance of more serious errors, such as generating
      incorrect index entries based on the original rather than the
      trigger-modified version of the row.
      
      In HEAD, change all of ExecBRInsertTriggers, ExecIRInsertTriggers,
      ExecBRUpdateTriggers, and ExecIRUpdateTriggers so that they continue to
      have similar APIs.  In the back branches I just changed
      ExecBRUpdateTriggers, since there is no bug in the ExecBRInsertTriggers
      case.
      e476eedd
  5. 16 2月, 2011 1 次提交
    • T
      Add CheckTableNotInUse calls in DROP TABLE and DROP INDEX. · a580bffa
      Tom Lane 提交于
      Recent releases had a check on rel->rd_refcnt in heap_drop_with_catalog,
      but failed to cover the possibility of pending trigger events at DROP time.
      (Before 8.4 we didn't even check the refcnt.)  When the trigger events were
      eventually fired, you'd get "could not open relation with OID nnn" errors,
      as in recent report from strk.  Better to throw a suitable error when the
      DROP is attempted.
      
      Also add a similar check in DROP INDEX.
      
      Back-patch to all supported branches.
      a580bffa
  6. 01 2月, 2011 2 次提交
  7. 28 1月, 2011 6 次提交
  8. 22 1月, 2011 1 次提交
    • T
      Fix pg_restore to do the right thing when escaping large objects. · 1a1167a1
      Tom Lane 提交于
      Specifically, this makes the workflow pg_dump -Fc -> pg_restore -> file
      produce correct output for BLOBs when the source database has
      standard_conforming_strings turned on.  It was already okay when that was
      off, or if pg_restore was told to restore directly into a database.
      
      This is a back-port of commit b1732111 of
      2009-08-04, with additional changes to emit old-style escaped bytea data
      instead of hex-style.  At the time, we had not heard of anyone encountering
      the problem in the field, so I judged it not worth the risk of changing
      back branches.  Now we do have a report, from Bosco Rama, so back-patch
      into 8.2 through 8.4.  9.0 and up are okay already.
      1a1167a1
  9. 18 1月, 2011 1 次提交
    • T
      Fix miscalculation of itemsafter in array_set_slice(). · b414dde4
      Tom Lane 提交于
      If the slice to be assigned to was before the existing array lower bound
      (requiring at least one null element to spring into existence to fill the
      gap), the code miscalculated how many entries needed to be copied from
      the old array's null bitmap.  This could result in trashing the array's
      data area (as seen in bug #5840 from Karsten Loesing), or worse.
      
      This has been broken since we first allowed the behavior of assigning to
      non-adjacent slices, in 8.2.  Back-patch to all affected versions.
      b414dde4
  10. 11 1月, 2011 1 次提交
  11. 10 1月, 2011 1 次提交
  12. 09 1月, 2011 1 次提交
  13. 05 1月, 2011 1 次提交
  14. 04 1月, 2011 1 次提交
  15. 29 12月, 2010 2 次提交
    • T
      Ooops, no DATE_IS_NOBEGIN/DATE_IS_NOEND in 8.3 or 8.2 ... · 5f588805
      Tom Lane 提交于
      I heard the siren call of git cherry-pick, but should have lashed myself
      to the mast.
      5f588805
    • T
      Avoid unexpected conversion overflow in planner for distant date values. · dcb2b356
      Tom Lane 提交于
      The "date" type supports a wider range of dates than int64 timestamps do.
      However, there is pre-int64-timestamp code in the planner that assumes that
      all date values can be converted to timestamp with impunity.  Fortunately,
      what we really need out of the conversion is always a double (float8)
      value; so even when the date is out of timestamp's range it's possible to
      produce a sane answer.  All we need is a code path that doesn't try to
      force the result into int64.  Per trouble report from David Rericha.
      
      Back-patch to all supported versions.  Although this is surely a corner
      case, there's not much point in advertising a date range wider than
      timestamp's if we will choke on such values in unexpected places.
      dcb2b356
  16. 20 12月, 2010 2 次提交
    • T
      Fix up handling of simple-form CASE with constant test expression. · a6a77ae4
      Tom Lane 提交于
      eval_const_expressions() can replace CaseTestExprs with constants when
      the surrounding CASE's test expression is a constant.  This confuses
      ruleutils.c's heuristic for deparsing simple-form CASEs, leading to
      Assert failures or "unexpected CASE WHEN clause" errors.  I had put in
      a hack solution for that years ago (see commit
      514ce7a3 of 2006-10-01), but bug #5794
      from Peter Speck shows that that solution failed to cover all cases.
      
      Fortunately, there's a much better way, which came to me upon reflecting
      that Peter's "CASE TRUE WHEN" seemed pretty redundant: we can "simplify"
      the simple-form CASE to the general form of CASE, by simply omitting the
      constant test expression from the rebuilt CASE construct.  This is
      intuitively valid because there is no need for the executor to evaluate
      the test expression at runtime; it will never be referenced, because any
      CaseTestExprs that would have referenced it are now replaced by constants.
      This won't save a whole lot of cycles, since evaluating a Const is pretty
      cheap, but a cycle saved is a cycle earned.  In any case it beats kluging
      ruleutils.c still further.  So this patch improves const-simplification
      and reverts the previous change in ruleutils.c.
      
      Back-patch to all supported branches.  The bug exists in 8.1 too, but it's
      out of warranty.
      a6a77ae4
    • T
      Fix erroneous parsing of tsquery input "... & !(subexpression) | ..." · d9b99b4b
      Tom Lane 提交于
      After parsing a parenthesized subexpression, we must pop all pending
      ANDs and NOTs off the stack, just like the case for a simple operand.
      Per bug #5793.
      
      Also fix clones of this routine in contrib/intarray and contrib/ltree,
      where input of types query_int and ltxtquery had the same problem.
      
      Back-patch to all supported versions.
      d9b99b4b
  17. 18 12月, 2010 1 次提交
  18. 16 12月, 2010 2 次提交
    • T
      Fix up getopt() reset management so it works on recent mingw. · 9fe5a62a
      Tom Lane 提交于
      The mingw people don't appear to care about compatibility with non-GNU
      versions of getopt, so force use of our own copy of getopt on Windows.
      Also, ensure that we make use of optreset when using our own copy.
      
      Per report from Andrew Dunstan.  Back-patch to all versions supported
      on Windows.
      9fe5a62a
    • T
      Fix contrib/seg's GiST picksplit method. · 04a1f093
      Tom Lane 提交于
      Fix the same size_alpha versus size_beta typo that was recently fixed
      in contrib/cube.  Noted by Alexander Korotkov.
      
      Back-patch to all supported branches (there is a more invasive fix in
      HEAD).
      04a1f093
  19. 14 12月, 2010 5 次提交
  20. 09 12月, 2010 1 次提交
    • T
      Force default wal_sync_method to be fdatasync on Linux. · 44dfc9cd
      Tom Lane 提交于
      Recent versions of the Linux system header files cause xlogdefs.h to
      believe that open_datasync should be the default sync method, whereas
      formerly fdatasync was the default on Linux.  open_datasync is a bad
      choice, first because it doesn't actually outperform fdatasync (in fact
      the reverse), and second because we try to use O_DIRECT with it, causing
      failures on certain filesystems (e.g., ext4 with data=journal option).
      This part of the patch is largely per a proposal from Marti Raudsepp.
      More extensive changes are likely to follow in HEAD, but this is as much
      change as we want to back-patch.
      
      Also clean up confusing code and incorrect documentation surrounding the
      fsync_writethrough option.  Those changes shouldn't result in any actual
      behavioral change, but I chose to back-patch them anyway to keep the
      branches looking similar in this area.
      
      In 9.0 and HEAD, also do some copy-editing on the WAL Reliability
      documentation section.
      
      Back-patch to all supported branches, since any of them might get used
      on modern Linux versions.
      44dfc9cd
  21. 07 12月, 2010 1 次提交
    • T
      Add a stack overflow check to copyObject(). · ee6c8875
      Tom Lane 提交于
      There are some code paths, such as SPI_execute(), where we invoke
      copyObject() on raw parse trees before doing parse analysis on them.  Since
      the bison grammar is capable of building heavily nested parsetrees while
      itself using only minimal stack depth, this means that copyObject() can be
      the front-line function that hits stack overflow before anything else does.
      Accordingly, it had better have a check_stack_depth() call.  I did a bit of
      performance testing and found that this slows down copyObject() by only a
      few percent, so the hit ought to be negligible in the context of complete
      processing of a query.
      
      Per off-list report from Toshihide Katayama.  Back-patch to all supported
      branches.
      ee6c8875
  22. 01 12月, 2010 1 次提交
    • T
      Prevent inlining a SQL function with multiple OUT parameters. · 0d45e8c5
      Tom Lane 提交于
      There were corner cases in which the planner would attempt to inline such
      a function, which would result in a failure at runtime due to loss of
      information about exactly what the result record type is.  Fix by disabling
      inlining when the function's recorded result type is RECORD.  There might
      be some sub-cases where inlining could still be allowed, but this is a
      simple and backpatchable fix, so leave refinements for another day.
      Per bug #5777 from Nate Carson.
      
      Back-patch to all supported branches.  8.1 happens to avoid a core-dump
      here, but it still does the wrong thing.
      0d45e8c5
  23. 27 11月, 2010 1 次提交
    • T
      Fix significant memory leak in contrib/xml2 functions. · 301a822a
      Tom Lane 提交于
      Most of the functions that execute XPath queries leaked the data structures
      created by libxml2.  This memory would not be recovered until end of
      session, so it mounts up pretty quickly in any serious use of the feature.
      Per report from Pavel Stehule, though this isn't his patch.
      
      Back-patch to all supported branches.
      301a822a
  24. 25 11月, 2010 1 次提交
  25. 20 11月, 2010 1 次提交
    • T
      Fix leakage of cost_limit when multiple autovacuum workers are active. · 6cb9d511
      Tom Lane 提交于
      When using default autovacuum_vac_cost_limit, autovac_balance_cost relied
      on VacuumCostLimit to contain the correct global value ... but after the
      first time through in a particular worker process, it didn't, because we'd
      trashed it in previous iterations.  Depending on the state of other autovac
      workers, this could result in a steady reduction of the effective
      cost_limit setting as a particular worker processed more and more tables,
      causing it to go slower and slower.  Spotted by Simon Poole (bug #5759).
      Fix by saving and restoring the GUC variables in the loop in do_autovacuum.
      
      In passing, improve a few comments.
      
      Back-patch to 8.3 ... the cost rebalancing code has been buggy since it was
      put in.
      6cb9d511