1. 19 2月, 2010 2 次提交
    • T
      Volatile-ize all five places where we expect a PG_TRY block to restore · 08181b42
      Tom Lane 提交于
      old memory context in plpython.  Before only one of them was marked
      volatile, but per report from Zdenek Kotala, some compilers do the
      wrong thing here.
      08181b42
    • T
      Fix ExecEvalArrayRef to pass down the old value of the array element or slice · 1a709257
      Tom Lane 提交于
      being assigned to, in case the expression to be assigned is a FieldStore that
      would need to modify that value.  The need for this was foreseen some time
      ago, but not implemented then because we did not have arrays of composites.
      Now we do, but the point evidently got overlooked in that patch.  Net result
      is that updating a field of an array element doesn't work right, as
      illustrated if you try the new regression test on an unpatched backend.
      Noted while experimenting with EXPLAIN VERBOSE, which has also got some issues
      in this area.
      
      Backpatch to 8.3, where arrays of composites were introduced.
      1a709257
  2. 17 2月, 2010 1 次提交
  3. 16 2月, 2010 1 次提交
  4. 15 2月, 2010 1 次提交
  5. 13 2月, 2010 1 次提交
  6. 12 2月, 2010 1 次提交
  7. 05 2月, 2010 1 次提交
    • H
      Add a note to the documentation of pg_standby that it's important that · a085a6a7
      Heikki Linnakangas 提交于
      the postgres process has permissions to delete the trigger file, per
      suggestion by Mason Hale.
      
      Also fix pg_standby to do a more predictable exit(200) instead of the
      current exit(-1) when the unlink of the trigger file fails anyway.
      
      This only affects 8.3 branch. Older versions didn't have pg_standby,
      and in 8.4 upwards pg_standby is no longer responsible for deleting the
      trigger file; it's supposed to be done by recovery_end_command instead.
      a085a6a7
  8. 04 2月, 2010 1 次提交
  9. 01 2月, 2010 2 次提交
    • T
      Change regexp engine's ccondissect/crevdissect routines to perform DFA · ff18ebfb
      Tom Lane 提交于
      matching before recursing instead of after.  The DFA match eliminates
      unworkable midpoint choices a lot faster than the recursive check, in most
      cases, so doing it first can speed things up; particularly in pathological
      cases such as recently exhibited by Michael Glaesemann.
      
      In addition, apply some cosmetic changes that were applied upstream (in the
      Tcl project) at the same time, in order to sync with upstream version 1.15
      of regexec.c.
      
      Upstream apparently intends to backpatch this, so I will too.  The
      pathological behavior could be unpleasant if encountered in the field,
      which seems to justify any risk of introducing new bugs.
      
      Tom Lane, reviewed by Donal K. Fellows of Tcl project
      ff18ebfb
    • M
      Fix race condition in win32 signal handling. · e00881bd
      Magnus Hagander 提交于
      There was a race condition where the receiving pipe could be closed by the
      child thread if the main thread was pre-empted before it got a chance to
      create a new one, and the dispatch thread ran to completion during that time.
      
      One symptom of this is that rows in pg_listener could be dropped under
      heavy load.
      
      Analysis and original patch by Radu Ilie, with some small
      modifications by Magnus Hagander.
      e00881bd
  10. 31 1月, 2010 1 次提交
    • T
      Avoid performing encoding conversion on command tag strings during EndCommand. · e488941a
      Tom Lane 提交于
      Since all current and foreseeable future command tags will be pure ASCII,
      there is no need to do conversion on them.  This saves a few cycles and also
      avoids polluting otherwise-pristine subtransaction memory contexts, which
      is the cause of the backend memory leak exhibited in bug #5302.  (Someday
      we'll probably want to have a better method of determining whether
      subtransaction contexts need to be kept around, but today is not that day.)
      
      Backpatch to 8.0.  The cycle-shaving aspect of this would work in 7.4
      too, but without subtransactions the memory-leak aspect doesn't apply,
      so it doesn't seem worth touching 7.4.
      e488941a
  11. 25 1月, 2010 2 次提交
    • T
      Apply Tcl_Init() to the "hold" interpreter created by pltcl. · acd294e9
      Tom Lane 提交于
      You might think this is unnecessary since that interpreter is never used
      to run code --- but it turns out that's wrong.  As of Tcl 8.5, the "clock"
      command (alone among builtin Tcl commands) is partially implemented by
      loaded-on-demand Tcl code, which means that it fails if there's not
      unknown-command support, and also that it's impossible to run it directly
      in a safe interpreter.  The way they get around the latter is that
      Tcl_CreateSlave() automatically sets up an alias command that forwards any
      execution of "clock" in a safe slave interpreter to its parent interpreter.
      Thus, when attempting to execute "clock" in trusted pltcl, the command
      actually executes in the "hold" interpreter, where it will fail if
      unknown-command support hasn't been introduced by sourcing the standard
      init.tcl script, which is done by Tcl_Init().  (This is a pretty dubious
      design decision on the Tcl boys' part, if you ask me ... but they didn't.)
      
      Back-patch all the way.  It's not clear that anyone would try to use ancient
      versions of pltcl with a recent Tcl, but it's not clear they wouldn't, either.
      Also add a regression test using "clock", in branches that have regression
      test support for pltcl.
      
      Per recent trouble report from Kyle Bateman.
      acd294e9
    • T
      Fix assorted core dumps and Assert failures that could occur during · 7309f334
      Tom Lane 提交于
      AbortTransaction or AbortSubTransaction, when trying to clean up after an
      error that prevented (sub)transaction start from completing:
      * access to TopTransactionResourceOwner that might not exist
      * assert failure in AtEOXact_GUC, if AtStart_GUC not called yet
      * assert failure or core dump in AfterTriggerEndSubXact, if
        AfterTriggerBeginSubXact not called yet
      
      Per testing by injecting elog(ERROR) at successive steps in StartTransaction
      and StartSubTransaction.  It's not clear whether all of these cases could
      really occur in the field, but at least one of them is easily exposed by
      simple stress testing, as per my accidental discovery yesterday.
      7309f334
  12. 24 1月, 2010 1 次提交
  13. 18 1月, 2010 1 次提交
  14. 14 1月, 2010 1 次提交
    • T
      When loading critical system indexes into the relcache, ensure we lock the · 8a6a40de
      Tom Lane 提交于
      underlying catalog not only the index itself.  Otherwise, if the cache
      load process touches the catalog (which will happen for many though not
      all of these indexes), we are locking index before parent table, which can
      result in a deadlock against processes that are trying to lock them in the
      normal order.  Per today's failure on buildfarm member gothic_moth; it's
      surprising the problem hadn't been identified before.
      
      Back-patch to 8.2.  Earlier releases didn't have the issue because they
      didn't try to lock these indexes during load (instead assuming that they
      couldn't change schema at all during multiuser operation).
      8a6a40de
  15. 13 1月, 2010 1 次提交
    • T
      Fix relcache reload mechanism to be more robust in the face of errors · d4b7cf06
      Tom Lane 提交于
      occurring during a reload, such as query-cancel.  Instead of zeroing out
      an existing relcache entry and rebuilding it in place, build a new relcache
      entry, then swap its contents with the old one, then free the new entry.
      This avoids problems with code believing that a previously obtained pointer
      to a cache entry must still reference a valid entry, as seen in recent
      failures on buildfarm member jaguar.  (jaguar is using CLOBBER_CACHE_ALWAYS
      which raises the probability of failure substantially, but the problem
      could occur in the field without that.)  The previous design was okay
      when it was made, but subtransactions and the ResourceOwner mechanism
      make it unsafe now.
      
      Also, make more use of the already existing rd_isvalid flag, so that we
      remember that the entry requires rebuilding even if the first attempt fails.
      
      Back-patch as far as 8.2.  Prior versions have enough issues around relcache
      reload anyway (due to inadequate locking) that fixing this one doesn't seem
      worthwhile.
      d4b7cf06
  16. 08 1月, 2010 1 次提交
    • T
      Make bit/varbit substring() treat any negative length as meaning "all the rest · f90acefc
      Tom Lane 提交于
      of the string".  The previous coding treated only -1 that way, and would
      produce an invalid result value for other negative values.
      
      We ought to fix it so that 2-parameter bit substring() is a different C
      function and the 3-parameter form throws error for negative length, but
      that takes a pg_proc change which is impractical in the back branches;
      and in any case somebody might be relying on -1 working this way.
      So just do this as a back-patchable fix.
      f90acefc
  17. 30 12月, 2009 3 次提交
    • T
      Set errno to zero before invoking SSL_read or SSL_write. It appears that · a6d3ec10
      Tom Lane 提交于
      at least in some Windows versions, these functions are capable of returning
      a failure indication without setting errno.  That puts us into an infinite
      loop if the previous value happened to be EINTR.  Per report from Brendan
      Hill.
      
      Back-patch to 8.2.  We could take it further back, but since this is only
      known to be an issue on Windows and we don't support Windows before 8.2,
      it does not seem worth the trouble.
      a6d3ec10
    • H
      Oops, previous backpatch applied incorrectly. · 0404cd5a
      Heikki Linnakangas 提交于
      0404cd5a
    • H
      Previous fix for temporary file management broke returning a set from · 67d25e5a
      Heikki Linnakangas 提交于
      PL/pgSQL function within an exception handler. Make sure we use the right
      resource owner when we create the tuplestore to hold returned tuples.
      
      Simplify tuplestore API so that the caller doesn't need to be in the right
      memory context when calling tuplestore_put* functions. tuplestore.c
      automatically switches to the memory context used when the tuplestore was
      created. Tuplesort was already modified like this earlier. This patch also
      removes the now useless MemoryContextSwitch calls from callers.
      
      Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
      the previous patch that broke this.
      67d25e5a
  18. 25 12月, 2009 1 次提交
  19. 13 12月, 2009 1 次提交
    • T
      Fix integer-to-bit-string conversions to handle the first fractional byte · 65a5d12b
      Tom Lane 提交于
      correctly when the output bit width is wider than the given integer by
      something other than a multiple of 8 bits.
      
      This has been wrong since I first wrote that code for 8.0 :-(.  Kudos to
      Roman Kononov for being the first to notice, though I didn't use his
      patch.  Per bug #5237.
      65a5d12b
  20. 10 12月, 2009 3 次提交
    • M
      · f2501310
      Marc G. Fournier 提交于
      tag 8.3.9
      f2501310
    • T
      8e692a9f
    • T
      Prevent indirect security attacks via changing session-local state within · e3b01bc1
      Tom Lane 提交于
      an allegedly immutable index function.  It was previously recognized that
      we had to prevent such a function from executing SET/RESET ROLE/SESSION
      AUTHORIZATION, or it could trivially obtain the privileges of the session
      user.  However, since there is in general no privilege checking for changes
      of session-local state, it is also possible for such a function to change
      settings in a way that might subvert later operations in the same session.
      Examples include changing search_path to cause an unexpected function to
      be called, or replacing an existing prepared statement with another one
      that will execute a function of the attacker's choosing.
      
      The present patch secures VACUUM, ANALYZE, and CREATE INDEX/REINDEX against
      these threats, which are the same places previously deemed to need protection
      against the SET ROLE issue.  GUC changes are still allowed, since there are
      many useful cases for that, but we prevent security problems by forcing a
      rollback of any GUC change after completing the operation.  Other cases are
      handled by throwing an error if any change is attempted; these include temp
      table creation, closing a cursor, and creating or deleting a prepared
      statement.  (In 7.4, the infrastructure to roll back GUC changes doesn't
      exist, so we settle for rejecting changes of "search_path" in these contexts.)
      
      Original report and patch by Gurjeet Singh, additional analysis by
      Tom Lane.
      
      Security: CVE-2009-4136
      e3b01bc1
  21. 09 12月, 2009 3 次提交
    • M
      Reject certificates with embedded NULLs in the commonName field. This stops · d7242375
      Magnus Hagander 提交于
      attacks where an attacker would put <attack>\0<propername> in the field and
      trick the validation code that the certificate was for <attack>.
      
      This is a very low risk attack since it reuqires the attacker to trick the
      CA into issuing a certificate with an incorrect field, and the common
      PostgreSQL deployments are with private CAs, and not external ones. Also,
      default mode in 8.4 does not do any name validation, and is thus also not
      vulnerable - but the higher security modes are.
      
      Backpatch all the way. Even though versions 8.3.x and before didn't have
      certificate name validation support, they still exposed this field for
      the user to perform the validation in the application code, and there
      is no way to detect this problem through that API.
      
      Security: CVE-2009-4034
      d7242375
    • T
      Update time zone data files to tzdata release 2009s: DST law changes in · d01b2e4e
      Tom Lane 提交于
      Antarctica, Argentina, Bangladesh, Fiji, Novokuznetsk, Pakistan, Palestine,
      Samoa, Syria.  Also historical corrections for Hong Kong.
      d01b2e4e
    • P
      Translation updates · d549d3e3
      Peter Eisentraut 提交于
      d549d3e3
  22. 03 12月, 2009 2 次提交
    • H
      Fix bug in temporary file management with subtransactions. A cursor opened · dd7321f8
      Heikki Linnakangas 提交于
      in a subtransaction stays open even if the subtransaction is aborted, so
      any temporary files related to it must stay alive as well. With the patch,
      we use ResourceOwners to track open temporary files and don't automatically
      close them at subtransaction end (though in the normal case temporary files
      are registered with the subtransaction resource owner and will therefore be
      closed).
      
      At end of top transaction, we still check that there's no temporary files
      marked as close-at-end-of-transaction open, but that's now just a debugging
      cross-check as the resource owner cleanup should've closed them already.
      dd7321f8
    • T
      Ignore attempts to set "application_name" in the connection startup packet. · 3c77fbd2
      Tom Lane 提交于
      This avoids a useless connection retry and complaint in the postmaster log
      when receiving a connection from 8.5 or later libpq.
      
      Backpatch in all supported branches, but of course *not* HEAD.
      3c77fbd2
  23. 01 12月, 2009 1 次提交
  24. 30 11月, 2009 1 次提交
  25. 25 11月, 2009 1 次提交
  26. 23 11月, 2009 1 次提交
    • H
      Fix an old bug in multixact and two-phase commit. Prepared transactions can · 0852c4d5
      Heikki Linnakangas 提交于
      be part of multixacts, so allocate a slot for each prepared transaction in
      the "oldest member" array in multixact.c. On PREPARE TRANSACTION, transfer
      the oldest member value from the current backends slot to the prepared xact
      slot. Also save and recover the value from the 2pc state file.
      
      The symptom of the bug was that after a transaction prepared, a shared lock
      still held by the prepared transaction was sometimes ignored by other
      transactions.
      
      Fix back to 8.1, where both 2PC and multixact were introduced.
      0852c4d5
  27. 19 11月, 2009 1 次提交
    • T
      Fix memory leak in syslogger: logfile_rotate() would leak a copy of the · 31f38e3f
      Tom Lane 提交于
      output filename if CSV logging was enabled and only one of the two possible
      output files got rotated during a particular call (which would, in fact,
      typically be the case during a size-based rotation).  This would amount to
      about MAXPGPATH (1KB) per rotation, and it's been there since the CSV
      code was put in, so it's surprising that nobody noticed it before.
      Per bug #5196 from Thomas Poindessous.
      31f38e3f
  28. 15 11月, 2009 1 次提交
  29. 14 11月, 2009 1 次提交
  30. 11 11月, 2009 1 次提交
    • T
      Do not build psql's flex module on its own, but instead include it in · 3b0d57eb
      Tom Lane 提交于
      mainloop.c.  This ensures that postgres_fe.h is read before including
      any system headers, which is necessary to avoid problems on some platforms
      where we make nondefault selections of feature macros for stdio.h or
      other headers.  We have had this policy for flex modules in the backend
      for many years, but for some reason it was not applied to psql.
      Per trouble report from Alexandra Roy and diagnosis by Albe Laurenz.
      3b0d57eb