1. 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
  2. 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
  3. 25 11月, 2010 1 次提交
  4. 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
  5. 16 11月, 2010 2 次提交
    • H
      The GiST scan algorithm uses LSNs to detect concurrent pages splits, but · f0682999
      Heikki Linnakangas 提交于
      temporary indexes are not WAL-logged. We used a constant LSN for temporary
      indexes, on the assumption that we don't need to worry about concurrent page
      splits in temporary indexes because they're only visible to the current
      session. But that assumption is wrong, it's possible to insert rows and
      split pages in the same session, while a scan is in progress. For example,
      by opening a cursor and fetching some rows, and INSERTing new rows before
      fetching some more.
      
      Fix by generating fake increasing LSNs, used in place of real LSNs in
      temporary GiST indexes.
      f0682999
    • T
      Fix aboriginal mistake in plpython's set-returning-function support. · 6a93cb68
      Tom Lane 提交于
      We must stay in the function's SPI context until done calling the iterator
      that returns the set result.  Otherwise, any attempt to invoke SPI features
      in the python code called by the iterator will malfunction.  Diagnosis and
      patch by Jan Urbanski, per bug report from Jean-Baptiste Quenot.
      
      Back-patch to 8.2; there was no support for SRFs in previous versions of
      plpython.
      6a93cb68
  6. 15 11月, 2010 1 次提交
  7. 13 11月, 2010 2 次提交
    • T
      Add missing outfuncs.c support for struct InhRelation. · 032191b4
      Tom Lane 提交于
      This is needed to support debug_print_parse, per report from Jon Nelson.
      Cursory testing via the regression tests suggests we aren't missing
      anything else.
      032191b4
    • T
      Fix old oversight in const-simplification of COALESCE() expressions. · 7b3c4a5d
      Tom Lane 提交于
      Once we have found a non-null constant argument, there is no need to
      examine additional arguments of the COALESCE.  The previous coding got it
      right only if the constant was in the first argument position; otherwise
      it tried to simplify following arguments too, leading to unexpected
      behavior like this:
      
      regression=# select coalesce(f1, 42, 1/0) from int4_tbl;
      ERROR:  division by zero
      
      It's a minor corner case, but a bug is a bug, so back-patch all the way.
      7b3c4a5d
  8. 12 11月, 2010 1 次提交
  9. 11 11月, 2010 1 次提交
    • T
      Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope. · 90e8efa3
      Tom Lane 提交于
      This code was just plain wrong: what you got was not a line through the
      given point but a line almost indistinguishable from the Y-axis, although
      not truly vertical.  The only caller that tries to use this function with
      m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal;
      it would end up producing the distance from the given point to the place
      where the lseg's line crosses the Y-axis.  That function is used by other
      operators too, so there are several operators that could compute wrong
      distances from a line segment to something else.  Per bug #5745 from
      jindiax.
      
      Back-patch to all supported branches.
      90e8efa3
  10. 10 11月, 2010 1 次提交
    • T
      Repair memory leakage while ANALYZE-ing complex index expressions. · 55425d37
      Tom Lane 提交于
      The general design of memory management in Postgres is that intermediate
      results computed by an expression are not freed until the end of the tuple
      cycle.  For expression indexes, ANALYZE has to re-evaluate each expression
      for each of its sample rows, and it wasn't bothering to free intermediate
      results until the end of processing of that index.  This could lead to very
      substantial leakage if the intermediate results were large, as in a recent
      example from Jakub Ouhrabka.  Fix by doing ResetExprContext for each sample
      row.  This necessitates adding a datumCopy step to ensure that the final
      expression value isn't recycled too.  Some quick testing suggests that this
      change adds at worst about 10% to the time needed to analyze a table with
      an expression index; which is annoying, but seems a tolerable price to pay
      to avoid unexpected out-of-memory problems.
      
      Back-patch to all supported branches.
      55425d37
  11. 09 11月, 2010 2 次提交
    • H
      In rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate the tuple · 6d2697ab
      Heikki Linnakangas 提交于
      length stored in the line pointer the same way it's calculated in the normal
      heap_insert() codepath. As noted by Jeff Davis, the length stored by
      raw_heap_insert() included padding but the one stored by the normal codepath
      did not. While the mismatch seems to be harmless, inconsistency isn't good,
      and the normal codepath has received a lot more testing over the years.
      
      Backpatch to 8.3 where the heap rewrite code was introduced.
      6d2697ab
    • T
      Fix error handling in temp-file deletion with log_temp_files active. · 99a87eda
      Tom Lane 提交于
      The original coding in FileClose() reset the file-is-temp flag before
      unlinking the file, so that if control came back through due to an error,
      it wouldn't try to unlink the file twice.  This was correct when written,
      but when the log_temp_files feature was added, the logging action was put
      in between those two steps.  An error occurring during the logging action
      --- such as a query cancel --- would result in the unlink not getting done
      at all, as in recent report from Michael Glaesemann.
      
      To fix this, make sure that we do both the stat and the unlink before doing
      anything that could conceivably CHECK_FOR_INTERRUPTS.  There is a judgment
      call here, which is which log message to emit first: if you can see only
      one, which should it be?  I chose to log unlink failure at the risk of
      losing the log_temp_files log message --- after all, if the unlink does
      fail, the temp file is still there for you to see.
      
      Back-patch to all versions that have log_temp_files.  The code was OK
      before that.
      99a87eda
  12. 07 11月, 2010 1 次提交
    • T
      Add support for detecting register-stack overrun on IA64. · 940de279
      Tom Lane 提交于
      Per recent investigation, the register stack can grow faster than the
      regular stack depending on compiler and choice of options.  To avoid
      crashes we must check both stacks in check_stack_depth().
      
      Back-patch to all supported versions.
      940de279
  13. 04 11月, 2010 1 次提交
    • T
      Reduce recursion depth in recently-added regression test. · 75991cb4
      Tom Lane 提交于
      Some buildfarm members fail the test with the original depth of 10 levels,
      apparently because they are running at the minimum max_stack_depth setting
      of 100kB and using ~ 10k per recursion level.  While it might be
      interesting to try to figure out why they're eating so much stack, it isn't
      likely that any fix for that would be back-patchable.  So just change the
      test to recurse only 5 levels.  The extra levels don't prove anything
      correctness-wise anyway.
      75991cb4
  14. 03 11月, 2010 1 次提交
    • T
      Ensure an index that uses a whole-row Var still depends on its table. · 34f89342
      Tom Lane 提交于
      We failed to record any dependency on the underlying table for an index
      declared like "create index i on t (foo(t.*))".  This would create trouble
      if the table were dropped without previously dropping the index.  To fix,
      simplify some overly-cute code in index_create(), accepting the possibility
      that sometimes the whole-table dependency will be redundant.  Also document
      this hazard in dependency.c.  Per report from Kevin Grittner.
      
      In passing, prevent a core dump in pg_get_indexdef() if the index's table
      can't be found.  I came across this while experimenting with Kevin's
      example.  Not sure it's a real issue when the catalogs aren't corrupt, but
      might as well be cautious.
      
      Back-patch to all supported versions.
      34f89342
  15. 29 10月, 2010 1 次提交
    • T
      Fix plpgsql's handling of "simple" expression evaluation. · ed78eefe
      Tom Lane 提交于
      In general, expression execution state trees aren't re-entrantly usable,
      since functions can store private state information in them.
      For efficiency reasons, plpgsql tries to cache and reuse state trees for
      "simple" expressions.  It can get away with that most of the time, but it
      can fail if the state tree is dirty from a previous failed execution (as
      in an example from Alvaro) or is being used recursively (as noted by me).
      
      Fix by tracking whether a state tree is in use, and falling back to the
      "non-simple" code path if so.  This results in a pretty considerable speed
      hit when the non-simple path is taken, but the available alternatives seem
      even more unpleasant because they add overhead in the simple path.  Per
      idea from Heikki.
      
      Back-patch to all supported branches.
      ed78eefe
  16. 28 10月, 2010 1 次提交
  17. 27 10月, 2010 1 次提交
  18. 21 10月, 2010 1 次提交
  19. 20 10月, 2010 1 次提交
    • T
      Fix ecpg test building process to not generate *.dSYM junk on Macs. · d109b10e
      Tom Lane 提交于
      The trick is to not try to build executables directly from .c files,
      but to always build the intermediate .o files.  For obscure reasons,
      Darwin's version of gcc will leave debug cruft behind in the first
      case but not the second.  Per complaint from Robert Haas.
      d109b10e
  20. 19 10月, 2010 1 次提交
  21. 12 10月, 2010 1 次提交
    • T
      Fix assorted bugs in GIN's WAL replay logic. · 2afd044c
      Tom Lane 提交于
      The original coding was quite sloppy about handling the case where
      XLogReadBuffer fails (because the page has since been deleted).  This
      would result in either "bad buffer id: 0" or an Assert failure during
      replay, if indeed the page were no longer there.  In a couple of places
      it also neglected to check whether the change had already been applied,
      which would probably result in corrupted index contents.  I believe that
      bug #5703 is an instance of the first problem.  These issues could show up
      without replication, but only if you were unfortunate enough to crash
      between modification of a GIN index and the next checkpoint.
      
      Back-patch to 8.2, which is as far back as GIN has WAL support.
      2afd044c
  22. 08 10月, 2010 2 次提交
  23. 03 10月, 2010 1 次提交
    • T
      Behave correctly if INSERT ... VALUES is decorated with additional clauses. · 392c66f1
      Tom Lane 提交于
      In versions 8.2 and up, the grammar allows attaching ORDER BY, LIMIT,
      FOR UPDATE, or WITH to VALUES, and hence to INSERT ... VALUES.  But the
      special-case code for VALUES in transformInsertStmt() wasn't expecting any
      of those, and just ignored them, leading to unexpected results.  Rather
      than complicate the special-case path, just ensure that the presence of any
      of those clauses makes us treat the query as if it had a general SELECT.
      Per report from Hitoshi Harada.
      392c66f1
  24. 01 10月, 2010 4 次提交
    • M
      Tag 8.3.12 · e32229ad
      Marc G. Fournier 提交于
      e32229ad
    • T
      Use a separate interpreter for each calling SQL userid in plperl and pltcl. · 3b4c327c
      Tom Lane 提交于
      There are numerous methods by which a Perl or Tcl function can subvert
      the behavior of another such function executed later; for example, by
      redefining standard functions or operators called by the target function.
      If the target function is SECURITY DEFINER, or is called by such a
      function, this means that any ordinary SQL user with Perl or Tcl language
      usage rights can do essentially anything with the privileges of the target
      function's owner.
      
      To close this security hole, create a separate Perl or Tcl interpreter for
      each SQL userid under which plperl or pltcl functions are executed within
      a session.  However, all plperlu or pltclu functions run within a session
      still share a single interpreter, since they all execute at the trust
      level of a database superuser anyway.
      
      Note: this change results in a functionality loss when libperl has been
      built without the "multiplicity" option: it's no longer possible to call
      plperl functions under different userids in one session, since such a
      libperl can't support multiple interpreters in one process.  However, such
      a libperl already failed to support concurrent use of plperl and plperlu,
      so it's likely that few people use such versions with Postgres.
      
      Security: CVE-2010-3433
      3b4c327c
    • P
      Translation updates for 8.3.12 · 65a192c4
      Peter Eisentraut 提交于
      65a192c4
    • T
      Update release notes for releases 9.0.1, 8.4.5, 8.3.12, 8.2.18, 8.1.22, · f7282fc9
      Tom Lane 提交于
      8.0.26, and 7.4.30.
      f7282fc9
  25. 29 9月, 2010 3 次提交
    • M
      Treat exit code 128 (ERROR_WAIT_NO_CHILDREN) as non-fatal on Win32, · 26b01668
      Magnus Hagander 提交于
      since it can happen when a process fails to start when the system
      is under high load.
      
      Per several bug reports and many peoples investigation.
      
      Back-patch to 8.2, since testing shows no issues even though the
      "deadman-switch" does not exist  in this version.
      26b01668
    • T
      Fix incorrect usage of non-strict OR joinclauses in appendrel indexscans. · a2e26a6f
      Tom Lane 提交于
      By chance I happened to notice that bug #5076 was still broken in the
      8.3 branch, though it worked everywhere else.  The reason is that 8.3's
      version of adjust_appendrel_attrs_mutator neglected to adjust
      RestrictInfo.nullable_relids.  This was an oversight in my patch of
      2009-04-16, which I apparently corrected in the later branches on
      2009-08-13 without realizing that it affected the 8.3 branch as well.
      By the time the bug report was filed, it was not reproducible in 8.4.
      I don't recall if I wrote it off as already fixed, or it just fell through
      the cracks; but anyway it's been a live bug in 8.3 for a year.
      a2e26a6f
    • T
      Fix another small oversight in command_no_begin patch. · 3e20490e
      Tom Lane 提交于
      Need a "return false" to prevent tests from continuing after we've moved
      the "query" pointer.  As it stood, it'd accept "DROP DISCARD ALL" as a
      match.
      3e20490e
  26. 28 9月, 2010 2 次提交
  27. 26 9月, 2010 1 次提交
    • T
      Further fixes to the pg_get_expr() security fix in back branches. · a824c59c
      Tom Lane 提交于
      It now emerges that the JDBC driver expects to be able to use pg_get_expr()
      on an output of a sub-SELECT.  So extend the check logic to be able to recurse
      into a sub-SELECT to see if the argument is ultimately coming from an
      appropriate column.  Per report from Thomas Kellerer.
      a824c59c
  28. 25 9月, 2010 1 次提交
  29. 24 9月, 2010 2 次提交
    • R
      Add contrib/xml2/pgxml.sql to .gitignore · 10079198
      Robert Haas 提交于
      Kevin Grittner
      10079198
    • T
      Prevent show_session_authorization from crashing when session_authorization · 7548ecb3
      Tom Lane 提交于
      hasn't been set.
      
      The only known case where this can happen is when show_session_authorization
      is invoked in an autovacuum process, which is possible if an index function
      calls it, as for example in bug #5669 from Andrew Geery.  We could perhaps
      try to return a sensible value, such as the name of the cluster-owning
      superuser; but that seems like much more trouble than the case is worth,
      and in any case it could create new possible failure modes.  Simply
      returning an empty string seems like the most appropriate fix.
      
      Back-patch to all supported versions, even those before autovacuum, just
      in case there's another way to provoke this crash.
      7548ecb3