1. 08 10月, 2009 1 次提交
  2. 03 10月, 2009 2 次提交
    • T
      Fix an oversight in an 8.3-era patch: pgstat_initstats should allow stats · 895a3fb6
      Tom Lane 提交于
      to be collected for sequences.
      
      Report and fix by Akira Kurosawa
      895a3fb6
    • T
      Fix erroneous handling of shared dependencies (ie dependencies on roles) · 81f73052
      Tom Lane 提交于
      in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
      as if a new function was being created, even if it wasn't, with two bad
      consequences: pg_shdepend might record the wrong owner for the function,
      and any dependencies for roles mentioned in the function's ACL would be lost.
      The fix is very easy: just don't touch pg_shdepend at all when doing a
      function replacement.
      
      Also update the CREATE FUNCTION reference page, which never explained
      exactly what changes and doesn't change in a function replacement.
      In passing, fix the CREATE VIEW reference page similarly; there's no
      code bug there, but the docs didn't say what happens.
      81f73052
  3. 29 9月, 2009 2 次提交
    • T
      Fix equivclass.c's not-quite-right strategy for handling X=X clauses. · 9cfc3d21
      Tom Lane 提交于
      The original coding correctly noted that these aren't just redundancies
      (they're effectively X IS NOT NULL, assuming = is strict).  However, they
      got treated that way if X happened to be in a single-member EquivalenceClass
      already, which could happen if there was an ORDER BY X clause, for instance.
      The simplest and most reliable solution seems to be to not try to process
      such clauses through the EquivalenceClass machinery; just throw them back
      for traditional processing.  The amount of work that'd be needed to be
      smarter than that seems out of proportion to the benefit.
      
      Per bug #5084 from Bernt Marius Johnsen, and analysis by Andrew Gierth.
      9cfc3d21
    • A
      Convert a perl array to a postgres array when returned by Set Returning... · eff805b5
      Andrew Dunstan 提交于
      Convert a perl array to a postgres array when returned by Set Returning Functions as well as non SRFs. Backpatch to 8.1 where these facilities were introduced. with a little help from Abhijit Menon-Sen.
      eff805b5
  4. 27 9月, 2009 1 次提交
    • T
      Fix RelationCacheInitializePhase2 (Phase3, in HEAD) to cope with the · 8b720b57
      Tom Lane 提交于
      possibility of shared-inval messages causing a relcache flush while it tries
      to fill in missing data in preloaded relcache entries.  There are actually
      two distinct failure modes here:
      
      1. The flush could delete the next-to-be-processed cache entry, causing
      the subsequent hash_seq_search calls to go off into the weeds.  This is
      the problem reported by Michael Brown, and I believe it also accounts
      for bug #5074.  The simplest fix is to restart the hashtable scan after
      we've read any new data from the catalogs.  It appears that pre-8.4
      branches have not suffered from this failure, because by chance there were
      no other catalogs sharing the same hash chains with the catalogs that
      RelationCacheInitializePhase2 had work to do for.  However that's obviously
      pretty fragile, and it seems possible that derivative versions with
      additional system catalogs might be vulnerable, so I'm back-patching this
      part of the fix anyway.
      
      2. The flush could delete the *current* cache entry, in which case the
      pointer to the newly-loaded data would end up being stored into an
      already-deleted Relation struct.  As long as it was still deleted, the only
      consequence would be some leaked space in CacheMemoryContext.  But it seems
      possible that the Relation struct could already have been recycled, in
      which case this represents a hard-to-reproduce clobber of cached data
      structures, with unforeseeable consequences.  The fix here is to pin the
      entry while we work on it.
      
      In passing, also change RelationCacheInitializePhase2 to Assert that
      formrdesc() set up the relation's cached TupleDesc (rd_att) with the
      correct type OID and hasoids values.  This is more appropriate than
      silently updating the values, because the original tupdesc might already
      have been copied into the catcache.  However this part of the patch is
      not in HEAD because it fails due to some questionable recent changes in
      formrdesc :-(.  That will be cleaned up in a subsequent patch.
      8b720b57
  5. 18 9月, 2009 1 次提交
  6. 14 9月, 2009 1 次提交
    • H
      Don't error out if recycling or removing an old WAL segment fails at the end · 1bb8236e
      Heikki Linnakangas 提交于
      of checkpoint. Although the checkpoint has been written to WAL at that point
      already, so that all data is safe, and we'll retry removing the WAL segment at
      the next checkpoint, if such a failure persists we won't be able to remove any
      other old WAL segments either and will eventually run out of disk space. It's
      better to treat the failure as non-fatal, and move on to clean any other WAL
      segment and continue with any other end-of-checkpoint cleanup.
      
      We don't normally expect any such failures, but on Windows it can happen with
      some anti-virus or backup software that lock files without FILE_SHARE_DELETE
      flag.
      
      Also, the loop in pgrename() to retry when the file is locked was broken. If a
      file is locked on Windows, you get ERROR_SHARE_VIOLATION, not
      ERROR_ACCESS_DENIED, at least on modern versions. Fix that, although I left
      the check for ERROR_ACCESS_DENIED in there as well (presumably it was correct
      in some environment), and added ERROR_LOCK_VIOLATION to be consistent with
      similar checks in pgwin32_open(). Reduce the timeout on the loop from 30s to
      10s, on the grounds that since it's been broken, we've effectively had a
      timeout of 0s and no-one has complained, so a smaller timeout is actually
      closer to the old behavior. A longer timeout would mean that if recycling a
      WAL file fails because it's locked for some reason, InstallXLogFileSegment()
      will hold ControlFileLock for longer, potentially blocking other backends, so
      a long timeout isn't totally harmless.
      
      While we're at it, set errno correctly in pgrename().
      
      Backpatch to 8.2, which is the oldest version supported on Windows. The xlog.c
      changes would make sense on other platforms and thus on older versions as
      well, but since there's no such locking issues on other platforms, it's not
      worth it.
      1bb8236e
  7. 10 9月, 2009 1 次提交
    • H
      On Windows, when a file is deleted and another process still has an open · 103be09c
      Heikki Linnakangas 提交于
      file handle on it, the file goes into "pending deletion" state where it
      still shows up in directory listing, but isn't accessible otherwise. That
      confuses RemoveOldXLogFiles(), making it think that the file hasn't been
      archived yet, while it actually was, and it was deleted along with the .done
      file.
      
      Fix that by renaming the file with ".deleted" extension before deleting it.
      Also check the return value of rename() and unlink(), so that if the removal
      fails for any reason (e.g another process is holding the file locked), we
      don't delete the .done file until the WAL file is really gone.
      
      Backpatch to 8.2, which is the oldest version supported on Windows.
      103be09c
  8. 08 9月, 2009 1 次提交
    • T
      Remove outside-the-scanner references to "yyleng". · a15cb065
      Tom Lane 提交于
      It seems the flex developers have decided to change yyleng from int to size_t.
      This has already happened in the latest release of OS X, and will start
      happening elsewhere once the next release of flex appears.  Rather than trying
      to divine how it's declared in any particular build, let's just remove the one
      existing not-very-necessary external usage.
      
      Back-patch to all supported branches; not so much because users in the field
      are likely to care about building old branches with cutting-edge flex, as
      to keep OSX-based buildfarm members from having problems with old branches.
      a15cb065
  9. 06 9月, 2009 1 次提交
  10. 04 9月, 2009 6 次提交
    • H
      Fix encoding handling in xml binary input function. If the XML header didn't · 691efa15
      Heikki Linnakangas 提交于
      specify an encoding explicitly, we used to treat it as being in database
      encoding when we parsed it, but then perform a UTF-8 -> database encoding
      conversion on it, which was completely bogus. It's now consistently treated as
      UTF-8.
      691efa15
    • M
      · e01fdca9
      Marc G. Fournier 提交于
      Tag 8.3.8
      e01fdca9
    • T
      7e2024be
    • T
      Make LOAD of an already-loaded library into a no-op, instead of attempting · 5927d9f6
      Tom Lane 提交于
      to unload and re-load the library.
      
      The difficulty with unloading a library is that we haven't defined safe
      protocols for doing so.  In particular, there's no safe mechanism for
      getting out of a "hook" function pointer unless libraries are unloaded
      in reverse order of loading.  And there's no mechanism at all for undefining
      a custom GUC variable, so GUC would be left with a pointer to an old value
      that might or might not still be valid, and very possibly wouldn't be in
      the same place anymore.
      
      While the unload and reload behavior had some usefulness in easing
      development of new loadable libraries, it's of no use whatever to normal
      users, so just disabling it isn't giving up that much.  Someday we might
      care to expend the effort to develop safe unload protocols; but even if
      we did, there'd be little certainty that every third-party loadable module
      was following them, so some security restrictions would still be needed.
      
      Back-patch to 8.2; before that, LOAD was superuser-only anyway.
      
      Security: unprivileged users could crash backend.  CVE not assigned yet
      5927d9f6
    • T
      Disallow RESET ROLE and RESET SESSION AUTHORIZATION inside security-definer · fe8170dc
      Tom Lane 提交于
      functions.
      
      This extends the previous patch that forbade SETting these variables inside
      security-definer functions.  RESET is equally a security hole, since it
      would allow regaining privileges of the caller; furthermore it can trigger
      Assert failures and perhaps other internal errors, since the code is not
      expecting these variables to change in such contexts.  The previous patch
      did not cover this case because assign hooks don't really have enough
      information, so move the responsibility for preventing this into guc.c.
      
      Problem discovered by Heikki Linnakangas.
      
      Security: no CVE assigned yet, extends CVE-2007-6600
      fe8170dc
    • P
      Translation updates · 095f7ba3
      Peter Eisentraut 提交于
      095f7ba3
  11. 03 9月, 2009 1 次提交
  12. 02 9月, 2009 1 次提交
    • T
      Fix pg_ctl's readfile() to not go into infinite loop on an empty file · bcdb5788
      Tom Lane 提交于
      (could happen if either postgresql.conf or postmaster.opts is empty).
      It's been broken since the C version was written for 8.0, so patch
      all the way back.
      
      initdb's copy of the function is broken in the same way, but it's
      less important there since the input files should never be empty.
      Patch that in HEAD only, and also fix some cosmetic differences that
      crept into that copy of the function.
      
      Per report from Corry Haines and Jeff Davis.
      bcdb5788
  13. 31 8月, 2009 1 次提交
  14. 27 8月, 2009 1 次提交
  15. 25 8月, 2009 2 次提交
    • A
      Avoid calling kill() in a postmaster signal handler. · fa837ad6
      Alvaro Herrera 提交于
      This causes problems when the system load is high, per report from Zdenek
      Kotala in <1250860954.1239.114.camel@localhost>; instead of calling kill
      directly, have the signal handler set a flag which is checked in ServerLoop.
      This way, the handler can return before being called again by a subsequent
      signal sent from the autovacuum launcher.  Also, increase the sleep in the
      launcher in this failure path to 1 second.
      
      Backpatch to 8.3, which is when the signalling between autovacuum
      launcher/postmaster was introduced.
      
      Also, add a couple of ReleasePostmasterChildSlot calls in error paths; this
      part backpatched to 8.4 which is when the child slot stuff was introduced.
      fa837ad6
    • T
      Fix inclusions of readline/editline header files so that we only attempt to · b040178c
      Tom Lane 提交于
      #include the version of history.h that is in the same directory as the
      readline.h we are using.  This avoids problems in some scenarios where both
      readline and editline are installed.  Report and patch by Zdenek Kotala.
      b040178c
  16. 19 8月, 2009 1 次提交
  17. 17 8月, 2009 2 次提交
  18. 16 8月, 2009 1 次提交
  19. 13 8月, 2009 1 次提交
    • T
      Fix old bug in log_autovacuum_min_duration code: it was relying on being able · 355e7ef4
      Tom Lane 提交于
      to access a Relation entry it had just closed.  I happened to be testing with
      CLOBBER_CACHE_ALWAYS, which made this a guaranteed core dump (at least on
      machines where sprintf %s isn't forgiving of a NULL pointer).  It's probably
      quite unlikely that it would fail in the field, but a bug is a bug.  Fix by
      moving the relation_close call down past the logging action.
      355e7ef4
  20. 11 8月, 2009 1 次提交
  21. 10 8月, 2009 2 次提交
  22. 08 8月, 2009 1 次提交
    • T
      Try to defend against the possibility that libpq is still in COPY_IN state · d9a00ebb
      Tom Lane 提交于
      when we reach the post-COPY "pump it dry" error recovery code that was added
      2006-11-24.  Per a report from Neil Best, there is at least one code path
      in which this occurs, leading to an infinite loop in code that's supposed
      to be making it more robust not less so.  A reasonable response seems to be
      to call PQputCopyEnd() again, so let's try that.
      
      Back-patch to all versions that contain the cleanup loop.
      d9a00ebb
  23. 07 8月, 2009 1 次提交
  24. 30 7月, 2009 1 次提交
  25. 29 7月, 2009 1 次提交
  26. 28 7月, 2009 1 次提交
  27. 25 7月, 2009 1 次提交
  28. 21 7月, 2009 1 次提交
  29. 18 7月, 2009 1 次提交
    • T
      Repair bug #4926 "too few pathkeys for mergeclauses". This example shows · d7bc5e30
      Tom Lane 提交于
      that the sanity checking I added to create_mergejoin_plan() in 8.3 was a
      few bricks shy of a load: the mergeclauses could reference pathkeys in a
      noncanonical order such as x,y,x, not only cases like x,x,y which is all
      that the code had allowed for.  The odd cases only turn up when using
      redundant clauses in an outer join condition, which is why no one had
      noticed before.
      d7bc5e30
  30. 14 7月, 2009 1 次提交
    • T
      Do a conditional SPI_push/SPI_pop when replanning a query in · b5f32d8d
      Tom Lane 提交于
      RevalidateCachedPlan.  This is to avoid a "SPI_ERROR_CONNECT" failure when
      the planner calls a SPI-using function and we are already inside one.
      The alternative fix is to expect callers of RevalidateCachedPlan to do this,
      which seems likely to result in additional hard-to-detect bugs of omission.
      Per reports from Frank van Vugt and Marek Lewczuk.
      
      Back-patch to 8.3. It's much harder to trigger the bug in 8.3, due to a
      smaller set of cases in which plans can be invalidated, but it could happen.
      (I think perhaps only a SI reset event could make 8.3 fail here, but that's
      certainly within the realm of possibility.)
      b5f32d8d