1. 01 6月, 2012 4 次提交
  2. 31 5月, 2012 3 次提交
    • T
      Update time zone data files to tzdata release 2012c. · e4f08846
      Tom Lane 提交于
      DST law changes in Antarctica, Armenia, Chile, Cuba, Falkland Islands,
      Gaza, Haiti, Hebron, Morocco, Syria, Tokelau Islands.
      Historical corrections for Canada.
      e4f08846
    • T
      Ignore SECURITY DEFINER and SET attributes for a PL's call handler. · 8851d5e9
      Tom Lane 提交于
      It's not very sensible to set such attributes on a handler function;
      but if one were to do so, fmgr.c went into infinite recursion because
      it would call fmgr_security_definer instead of the handler function proper.
      There is no way for fmgr_security_definer to know that it ought to call the
      handler and not the original function referenced by the FmgrInfo's fn_oid,
      so it tries to do the latter, causing the whole process to start over
      again.
      
      Ordinarily such misconfiguration of a procedural language's handler could
      be written off as superuser error.  However, because we allow non-superuser
      database owners to create procedural languages and the handler for such a
      language becomes owned by the database owner, it is possible for a database
      owner to crash the backend, which ideally shouldn't be possible without
      superuser privileges.  In 9.2 and up we will adjust things so that the
      handler functions are always owned by superusers, but in existing branches
      this is a minor security fix.
      
      Problem noted by Noah Misch (after several of us had failed to detect
      it :-().  This is CVE-2012-2655.
      8851d5e9
    • T
      Expand the allowed range of timezone offsets to +/-15:59:59 from Greenwich. · 4d3482a7
      Tom Lane 提交于
      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.
      4d3482a7
  3. 30 5月, 2012 1 次提交
    • T
      Fix incorrect password transformation in contrib/pgcrypto's DES crypt(). · dd957a5b
      Tom Lane 提交于
      Overly tight coding caused the password transformation loop to stop
      examining input once it had processed a byte equal to 0x80.  Thus, if the
      given password string contained such a byte (which is possible though not
      highly likely in UTF8, and perhaps also in other non-ASCII encodings), all
      subsequent characters would not contribute to the hash, making the password
      much weaker than it appears on the surface.
      
      This would only affect cases where applications used DES crypt() to encode
      passwords before storing them in the database.  If a weak password has been
      created in this fashion, the hash will stop matching after this update has
      been applied, so it will be easy to tell if any passwords were unexpectedly
      weak.  Changing to a different password would be a good idea in such a case.
      (Since DES has been considered inadequately secure for some time, changing
      to a different encryption algorithm can also be recommended.)
      
      This code, and the bug, are shared with at least PHP, FreeBSD, and OpenBSD.
      Since the other projects have already published their fixes, there is no
      point in trying to keep this commit private.
      
      This bug has been assigned CVE-2012-2143, and credit for its discovery goes
      to Rubin Xu and Joseph Bonneau.
      dd957a5b
  4. 29 5月, 2012 1 次提交
    • T
      Teach AbortOutOfAnyTransaction to clean up partially-started transactions. · b3d9db46
      Tom Lane 提交于
      AbortOutOfAnyTransaction failed to do anything if the state it saw on
      entry corresponded to failing partway through StartTransaction.  I fixed
      AbortCurrentTransaction to cope with that case way back in commit
      60b2444c, but evidently overlooked that
      AbortOutOfAnyTransaction should do likewise.
      
      Back-patch to all supported branches.  It's not clear that this omission
      has any more-than-cosmetic consequences, but it's also not clear that it
      doesn't, so back-patching seems the least risky choice.
      b3d9db46
  5. 27 5月, 2012 1 次提交
    • T
      Prevent synchronized scanning when systable_beginscan chooses a heapscan. · 422022b1
      Tom Lane 提交于
      The only interesting-for-performance case wherein we force heapscan here
      is when we're rebuilding the relcache init file, and the only such case
      that is likely to be examining a catalog big enough to be syncscanned is
      RelationBuildTupleDesc.  But the early-exit optimization in that code gets
      broken if we start the scan at a random place within the catalog, so that
      allowing syncscan is actually a big deoptimization if pg_attribute is large
      (at least for the normal case where the rows for core system catalogs have
      never been changed since initdb).  Hence, prevent syncscan here.  Per my
      testing pursuant to complaints from Jeff Frost and Greg Sabino Mullane,
      though neither of them seem to have actually hit this specific problem.
      
      Back-patch to 8.3, where syncscan was introduced.
      422022b1
  6. 26 5月, 2012 2 次提交
    • T
      Fix string truncation to be multibyte-aware in text_name and bpchar_name. · 6f163609
      Tom Lane 提交于
      Previously, casts to name could generate invalidly-encoded results.
      
      Also, make these functions match namein() more exactly, by consistently
      using palloc0() instead of ad-hoc zeroing code.
      
      Back-patch to all supported branches.
      
      Karl Schnaitter and Tom Lane
      6f163609
    • T
      Use binary search instead of brute-force scan in findNamespace(). · bd43c50a
      Tom Lane 提交于
      The previous coding presented a significant bottleneck when dumping
      databases containing many thousands of schemas, since the total time
      spent searching would increase roughly as O(N^2) in the number of objects.
      Noted by Jeff Janes, though I rewrote his proposed patch to use the
      existing findObjectByOid infrastructure.
      
      Since this is a longstanding performance bug, backpatch to all supported
      versions.
      bd43c50a
  7. 23 5月, 2012 1 次提交
    • T
      Ensure that seqscans check for interrupts at least once per page. · c994b921
      Tom Lane 提交于
      If a seqscan encounters many consecutive pages containing only dead tuples,
      it can remain in the loop in heapgettup for a long time, and there was no
      CHECK_FOR_INTERRUPTS anywhere in that loop.  This meant there were
      real-world situations where a query would be effectively uncancelable for
      long stretches.  Add a check placed to occur once per page, which should be
      enough to provide reasonable response time without adding any measurable
      overhead.
      
      Report and patch by Merlin Moncure (though I tweaked it a bit).
      Back-patch to all supported branches.
      c994b921
  8. 16 5月, 2012 1 次提交
  9. 11 5月, 2012 1 次提交
    • T
      Fix Windows implementation of PGSemaphoreLock. · fcc0ba31
      Tom Lane 提交于
      The original coding failed to reset ImmediateInterruptOK before returning,
      which would potentially allow a subsequent query-cancel interrupt to be
      accepted at an unsafe point.  This is a really nasty bug since it's so hard
      to predict the consequences, but they could be unpleasant.
      
      Also, ensure that signal handlers are serviced before this function
      returns, even if the semaphore is already set.  This should make the
      behavior more like Unix.
      
      Back-patch to all supported versions.
      fcc0ba31
  10. 03 5月, 2012 1 次提交
  11. 28 4月, 2012 1 次提交
    • T
      Fix printing of whole-row Vars at top level of a SELECT targetlist. · 092d1d9d
      Tom Lane 提交于
      Normally whole-row Vars are printed as "tabname.*".  However, that does not
      work at top level of a targetlist, because per SQL standard the parser will
      think that the "*" should result in column-by-column expansion; which is
      not at all what a whole-row Var implies.  We used to just print the table
      name in such cases, which works most of the time; but it fails if the table
      name matches a column name available anywhere in the FROM clause.  This
      could lead for instance to a view being interpreted differently after dump
      and reload.  Adding parentheses doesn't fix it, but there is a reasonably
      simple kluge we can use instead: attach a no-op cast, so that the "*" isn't
      syntactically at top level anymore.  This makes the printing of such
      whole-row Vars a lot more consistent with other Vars, and may indeed fix
      more cases than just the reported one; I'm suspicious that cases involving
      schema qualification probably didn't work properly before, either.
      
      Per bug report and fix proposal from Abbas Butt, though this patch is quite
      different in detail from his.
      
      Back-patch to all supported versions.
      092d1d9d
  12. 27 4月, 2012 1 次提交
    • T
      Fix syslogger's rotation disable/re-enable logic. · f8d7f9ad
      Tom Lane 提交于
      If it fails to open a new log file, the syslogger assumes there's something
      wrong with its parameters (such as log_directory), and stops attempting
      automatic time-based or size-based log file rotations.  Sending it SIGHUP
      is supposed to start that up again.  However, the original coding for that
      was really bogus, involving clobbering a couple of GUC variables and hoping
      that SIGHUP processing would restore them.  Get rid of that technique in
      favor of maintaining a separate flag showing we've turned rotation off.
      Per report from Mark Kirkwood.
      
      Also, the syslogger will automatically attempt to create the log_directory
      directory if it doesn't exist, but that was only happening at startup.
      For consistency and ease of use, it should do the same whenever the value
      of log_directory is changed by SIGHUP.
      
      Back-patch to all supported branches.
      f8d7f9ad
  13. 26 4月, 2012 1 次提交
    • T
      Fix edge-case behavior of pg_next_dst_boundary(). · 17fc5db7
      Tom Lane 提交于
      Due to rather sloppy thinking (on my part, I'm afraid) about the
      appropriate behavior for boundary conditions, pg_next_dst_boundary() gave
      undefined, platform-dependent results when the input time is exactly the
      last recorded DST transition time for the specified time zone, as a result
      of fetching values one past the end of its data arrays.
      
      Change its specification to be that it always finds the next DST boundary
      *after* the input time, and adjust code to match that.  The sole existing
      caller, DetermineTimeZoneOffset, doesn't actually care about this
      distinction, since it always uses a probe time earlier than the instant
      that it does care about.  So it seemed best to me to change the API to make
      the result=1 and result=0 cases more consistent, specifically to ensure
      that the "before" outputs always describe the state at the given time,
      rather than hacking the code to obey the previous API comment exactly.
      
      Per bug #6605 from Sergey Burladyan.  Back-patch to all supported versions.
      17fc5db7
  14. 18 4月, 2012 3 次提交
  15. 12 4月, 2012 1 次提交
    • T
      Clamp indexscan filter condition cost estimate to be not less than zero. · 67a48385
      Tom Lane 提交于
      cost_index tries to estimate the per-tuple costs of evaluating filter
      conditions (a/k/a qpquals) by subtracting the estimated cost of the
      indexqual conditions from that of the baserestrictinfo conditions.  This is
      correct so long as the indexquals list is a subset of the baserestrictinfo
      list.  However, in the presence of derived indexable conditions it's
      completely wrong, leading to bogus or even negative scan cost estimates,
      as seen for example in bug #6579 from Istvan Endredy.  In practice the
      problem isn't severe except in the specific case of a LIKE optimization on
      a functional index containing a very expensive function.
      
      A proper fix for this might change cost estimates by more than people would
      like for stable branches, so in the back branches let's just clamp the cost
      difference to be not less than zero.  That will at least prevent completely
      insane behavior, while not changing the results normally.
      67a48385
  16. 09 4月, 2012 3 次提交
    • T
      Fix an Assert that turns out to be reachable after all. · 454c7fb3
      Tom Lane 提交于
      estimate_num_groups() gets unhappy with
      	create table empty();
      	select * from empty except select * from empty e2;
      I can't see any actual use-case for such a query (and the table is illegal
      per SQL spec), but it seems like a good idea that it not cause an assert
      failure.
      454c7fb3
    • H
      set_stack_base() no longer needs to be called in PostgresMain. · 2f8659b0
      Heikki Linnakangas 提交于
      This was a thinko in previous commit. Now that stack base pointer is now set
      in PostmasterMain and SubPostmasterMain, it doesn't need to be set in
      PostgresMain anymore.
      2f8659b0
    • H
      Do stack-depth checking in all postmaster children. · ddeac5de
      Heikki Linnakangas 提交于
      We used to only initialize the stack base pointer when starting up a regular
      backend, not in other processes. In particular, autovacuum workers can run
      arbitrary user code, and without stack-depth checking, infinite recursion
      in e.g an index expression will bring down the whole cluster.
      
      The comment about PL/Java using set_stack_base() is not yet true. As the
      code stands, PL/java still modifies the stack_base_ptr variable directly.
      However, it's been discussed in the PL/Java mailing list that it should be
      changed to use the function, because PL/Java is currently oblivious to the
      register stack used on Itanium. There's another issues with PL/Java, namely
      that the stack base pointer it sets is not really the base of the stack, it
      could be something close to the bottom of the stack. That's a separate issue
      that might need some further changes to this code, but that's a different
      story.
      
      Backpatch to all supported releases.
      ddeac5de
  17. 07 4月, 2012 1 次提交
  18. 05 4月, 2012 1 次提交
    • T
      Fix syslogger to not lose log coherency under high load. · e98fc8c4
      Tom Lane 提交于
      The original coding of the syslogger had an arbitrary limit of 20 large
      messages concurrently in progress, after which it would just punt and dump
      message fragments to the output file separately.  Our ambitions are a bit
      higher than that now, so allow the data structure to expand as necessary.
      
      Reported and patched by Andrew Dunstan; some editing by Tom
      e98fc8c4
  19. 04 4月, 2012 1 次提交
    • T
      Fix a couple of contrib/dblink bugs. · 11efdb06
      Tom Lane 提交于
      dblink_exec leaked temporary database connections if any error occurred
      after connection setup, for example
      	SELECT dblink_exec('...connect string...', 'select 1/0');
      Add a PG_TRY block to ensure PQfinish gets done when it is needed.
      (dblink_record_internal is on the hairy edge of needing similar treatment,
      but seems not to be actively broken at the moment.)
      
      Also, in 9.0 and up, only one of the three functions using tuplestore
      return mode was properly checking that the query context would allow
      a tuplestore result.
      
      Noted while reviewing dblink patch.  Back-patch to all supported branches.
      11efdb06
  20. 01 4月, 2012 2 次提交
    • T
      Fix O(N^2) behavior in pg_dump when many objects are in dependency loops. · b1be1294
      Tom Lane 提交于
      Combining the loop workspace with the record of already-processed objects
      might have been a cute trick, but it behaves horridly if there are many
      dependency loops to repair: the time spent in the first step of findLoop()
      grows as O(N^2).  Instead use a separate flag array indexed by dump ID,
      which we can check in constant time.  The length of the workspace array
      is now never more than the actual length of a dependency chain, which
      should be reasonably short in all cases of practical interest.  The code
      is noticeably easier to understand this way, too.
      
      Per gripe from Mike Roest.  Since this is a longstanding performance bug,
      backpatch to all supported versions.
      b1be1294
    • T
      Fix O(N^2) behavior in pg_dump for large numbers of owned sequences. · 55eb2567
      Tom Lane 提交于
      The loop that matched owned sequences to their owning tables required time
      proportional to number of owned sequences times number of tables; although
      this work was only expended in selective-dump situations, which is probably
      why the issue wasn't recognized long since.  Refactor slightly so that we
      can perform this work after the index array for findTableByOid has been
      set up, reducing the time to O(M log N).
      
      Per gripe from Mike Roest.  Since this is a longstanding performance bug,
      backpatch to all supported versions.
      55eb2567
  21. 23 3月, 2012 1 次提交
    • T
      Fix GET DIAGNOSTICS for case of assignment to function's first variable. · 38350a49
      Tom Lane 提交于
      An incorrect and entirely unnecessary "safety check" in exec_stmt_getdiag()
      caused the code to treat an assignment to a variable with dno zero as a
      no-op.  Unfortunately, that's a perfectly valid dno.  This has been broken
      since GET DIAGNOSTICS was invented.  It's not terribly surprising that the
      bug went unnoticed for so long, since in most cases you probably wouldn't
      use the function's first-created variable (normally its first parameter)
      as a GET DIAGNOSTICS target.  Nonetheless, it's broken.  Per bug #6551
      from Adam Buraczewski.
      38350a49
  22. 22 3月, 2012 1 次提交
    • R
      Don't allow CREATE TABLE AS to put relations in pg_global. · 596e1632
      Robert Haas 提交于
      This was never intended to be allowed, and is blocked for an ordinary
      CREATE TABLE, but CREATE TABLE AS slipped through the cracks.  This
      commit won't do anything to fix existing cases where this has loophole
      has been exploited, but it still seems prudent to lock it down going
      forward.
      
      Back-branch commit only, as this problem has been refactored away
      on the master branch.
      
      Andres Freund
      596e1632
  23. 21 3月, 2012 1 次提交
  24. 18 3月, 2012 1 次提交
    • A
      Honor inputdir and outputdir when converting regression files. · 206f5b08
      Andrew Dunstan 提交于
      When converting source files, pg_regress' inputdir and outputdir options were
      ignored when computing the locations of the destination files. In consequence,
      these options were effectively unusable when the regression inputs need to
      be adjusted by pg_regress. This patch makes pg_regress put the converted files
      in the same place that these options specify non-converted input or results
      files are to be found. Backpatched to all live branches.
      206f5b08
  25. 11 3月, 2012 1 次提交
  26. 06 3月, 2012 1 次提交
    • T
      Improve documentation around logging_collector and use of stderr. · 3713ca86
      Tom Lane 提交于
      In backup.sgml, point out that you need to be using the logging collector
      if you want to log messages from a failing archive_command script.  (This
      is an oversimplification, in that it will work without the collector as
      long as you're not sending postmaster stderr to /dev/null; but it seems
      like a good idea to encourage use of the collector to avoid problems
      with multiple processes concurrently scribbling on one file.)
      
      In config.sgml, do some wordsmithing of logging_collector discussion.
      
      Per bug #6518 from Janning Vygen
      3713ca86
  27. 24 2月, 2012 3 次提交
    • T
      Stamp 8.3.18. · 82345d87
      Tom Lane 提交于
      82345d87
    • T
      Last-minute release note updates. · ecabae5a
      Tom Lane 提交于
      Security: CVE-2012-0866, CVE-2012-0867, CVE-2012-0868
      ecabae5a
    • T
      Convert newlines to spaces in names written in pg_dump comments. · a7f6cb85
      Tom Lane 提交于
      pg_dump was incautious about sanitizing object names that are emitted
      within SQL comments in its output script.  A name containing a newline
      would at least render the script syntactically incorrect.  Maliciously
      crafted object names could present a SQL injection risk when the script
      is reloaded.
      
      Reported by Heikki Linnakangas, patch by Robert Haas
      
      Security: CVE-2012-0868
      a7f6cb85