Skip to content
Snippets Groups Projects
  1. May 11, 2013
  2. May 10, 2013
    • Tom Lane's avatar
      Guard against input_rows == 0 in estimate_num_groups(). · 4ebbbf3c
      Tom Lane authored
      This case doesn't normally happen, because the planner usually clamps
      all row estimates to at least one row; but I found that it can arise
      when dealing with relations excluded by constraints.  Without a defense,
      estimate_num_groups() can return zero, which leads to divisions by zero
      inside the planner as well as assertion failures in the executor.
      
      An alternative fix would be to change set_dummy_rel_pathlist() to make
      the size estimate for a dummy relation 1 row instead of 0, but that seemed
      pretty ugly; and probably someday we'll want to drop the convention that
      the minimum rowcount estimate is 1 row.
      
      Back-patch to 8.4, as the problem can be demonstrated that far back.
      4ebbbf3c
    • Tom Lane's avatar
      Fix pgp_pub_decrypt() so it works for secret keys with passwords. · a184461a
      Tom Lane authored
      Per report from Keith Fiske.
      
      Marko Kreen
      a184461a
    • Tom Lane's avatar
      Fix management of fn_extra caching during repeated GiST index scans. · eb6cc854
      Tom Lane authored
      Commit d22a09dc introduced official support
      for GiST consistentFns that want to cache data using the FmgrInfo fn_extra
      pointer: the idea was to preserve the cached values across gistrescan(),
      whereas formerly they'd been leaked.  However, there was an oversight in
      that, namely that multiple scan keys might reference the same column's
      consistentFn; the code would result in propagating the same cache value
      into multiple scan keys, resulting in crashes or wrong answers.  Use a
      separate array instead to ensure that each scan key keeps its own state.
      
      Per bug #8143 from Joel Roller.  Back-patch to 9.2 where the bug was
      introduced.
      eb6cc854
  3. May 09, 2013
    • Tom Lane's avatar
      Use pg_dump's --quote-all-identifiers option in pg_upgrade. · 44f5bb24
      Tom Lane authored
      This helps guard against changes in the set of reserved keywords from
      one version to another.  In theory it should only be an issue if we
      de-reserve a keyword in a newer release, since that can create the type
      of problem shown in bug #8128.
      
      Back-patch to 9.1 where the --quote-all-identifiers option was added.
      44f5bb24
  4. May 08, 2013
  5. May 04, 2013
  6. May 02, 2013
    • Heikki Linnakangas's avatar
      Fix thinko in comment. · 7fa56e63
      Heikki Linnakangas authored
      WAL segment means a 16 MB physical WAL file; this comment meant a logical
      4 GB log file.
      
      Amit Langote. Apply to backbranches only, as the comment is gone in master.
      7fa56e63
    • Tom Lane's avatar
      Fix permission tests for views/tables proven empty by constraint exclusion. · 15b04210
      Tom Lane authored
      A view defined as "select <something> where false" had the curious property
      that the system wouldn't check whether users had the privileges necessary
      to select from it.  More generally, permissions checks could be skipped
      for tables referenced in sub-selects or views that were proven empty by
      constraint exclusion (although some quick testing suggests this seldom
      happens in cases of practical interest).  This happened because the planner
      failed to include rangetable entries for such tables in the finished plan.
      
      This was noticed in connection with erroneous handling of materialized
      views, but actually the issue is quite unrelated to matviews.  Therefore,
      revert commit 200ba166 in favor of a more
      direct test for the real problem.
      
      Back-patch to 9.2 where the bug was introduced (by commit
      7741dd65).
      15b04210
  7. Apr 30, 2013
    • Heikki Linnakangas's avatar
      Install recycled WAL segments with current timeline ID during recovery. · 4aed94f1
      Heikki Linnakangas authored
      This is a follow-up to the earlier fix, which changed the recycling logic
      to recycle WAL segments under the current recovery target timeline. That
      turns out to be a bad idea, because installing a recycled segment with
      a TLI higher than what we're recovering at the moment means that the recovery
      logic will find the recycled WAL segment and try to replay it. It will fail,
      but but the mere presence of such a WAL segment will mask any other, real,
      file with the same log/seg, but smaller TLI.
      
      Per report from Mitsumasa Kondo. Apply to 9.1 and 9.2, like the previous
      fix. Master was already doing this differently; this patch makes 9.1 and
      9.2 to do the same thing as master.
      4aed94f1
  8. Apr 29, 2013
    • Tom Lane's avatar
      Postpone creation of pathkeys lists to fix bug #8049. · 841c9b6b
      Tom Lane authored
      This patch gets rid of the concept of, and infrastructure for,
      non-canonical PathKeys; we now only ever create canonical pathkey lists.
      
      The need for non-canonical pathkeys came from the desire to have
      grouping_planner initialize query_pathkeys and related pathkey lists before
      calling query_planner.  However, since query_planner didn't actually *do*
      anything with those lists before they'd been made canonical, we can get rid
      of the whole mess by just not creating the lists at all until the point
      where we formerly canonicalized them.
      
      There are several ways in which we could implement that without making
      query_planner itself deal with grouping/sorting features (which are
      supposed to be the province of grouping_planner).  I chose to add a
      callback function to query_planner's API; other alternatives would have
      required adding more fields to PlannerInfo, which while not bad in itself
      would create an ABI break for planner-related plugins in the 9.2 release
      series.  This still breaks ABI for anything that calls query_planner
      directly, but it seems somewhat unlikely that there are any such plugins.
      
      I had originally conceived of this change as merely a step on the way to
      fixing bug #8049 from Teun Hoogendoorn; but it turns out that this fixes
      that bug all by itself, as per the added regression test.  The reason is
      that now get_eclass_for_sort_expr is adding the ORDER BY expression at the
      end of EquivalenceClass creation not the start, and so anything that is in
      a multi-member EquivalenceClass has already been created with correct
      em_nullable_relids.  I am suspicious that there are related scenarios in
      which we still need to teach get_eclass_for_sort_expr to compute correct
      nullable_relids, but am not eager to risk destabilizing either 9.2 or 9.3
      to fix bugs that are only hypothetical.  So for the moment, do this and
      stop here.
      
      Back-patch to 9.2 but not to earlier branches, since they don't exhibit
      this bug for lack of join-clause-movement logic that depends on
      em_nullable_relids being correct.  (We might have to revisit that choice
      if any related bugs turn up.)  In 9.2, don't change the signature of
      make_pathkeys_for_sortclauses nor remove canonicalize_pathkeys, so as
      not to risk more plugin breakage than we have to.
      841c9b6b
    • Kevin Grittner's avatar
      Ensure ANALYZE phase is not skipped because of canceled truncate. · 95909f3b
      Kevin Grittner authored
      Patch b19e4250 attempted to
      preserve existing behavior regarding statistics generation in the
      case that a truncation attempt was canceled due to lock conflicts.
      It failed to do this accurately in two regards: (1) autovacuum had
      previously generated statistics if the truncate attempt failed to
      initially get the lock rather than having started the attempt, and
      (2) the VACUUM ANALYZE command had always generated statistics.
      
      Both of these changes were unintended, and are reverted by this
      patch.  On review, there seems to be consensus that the previous
      failure to generate statistics when the truncate was terminated
      was more an unfortunate consequence of how that effort was
      previously terminated than a feature we want to keep; so this
      patch generates statistics even when an autovacuum truncation
      attempt terminates early.  Another unintended change which is kept
      on the basis that it is an improvement is that when a VACUUM
      command is truncating, it will the new heuristic for avoiding
      blocking other processes, rather than keeping an
      AccessExclusiveLock on the table for however long the truncation
      takes.
      
      Per multiple reports, with some renaming per patch by Jeff Janes.
      
      Backpatch to 9.0, where problem was created.
      95909f3b
  9. Apr 26, 2013
    • Joe Conway's avatar
      Ensure that user created rows in extension tables get dumped if the table is... · 4dbe52d3
      Joe Conway authored
      Ensure that user created rows in extension tables get dumped if the table is explicitly requested, either with a -t/--table switch of the table itself, or by -n/--schema switch of the schema containing the extension table. Patch reviewed by Vibhor Kumar and Dimitri Fontaine.
      
      Backpatched to 9.1 when the extension management facility was added.
      4dbe52d3
  10. Apr 25, 2013
  11. Apr 22, 2013
  12. Apr 20, 2013
    • Tom Lane's avatar
      Fix longstanding race condition in plancache.c. · c37ec840
      Tom Lane authored
      When creating or manipulating a cached plan for a transaction control
      command (particularly ROLLBACK), we must not perform any catalog accesses,
      since we might be in an aborted transaction.  However, plancache.c busily
      saved or examined the search_path for every cached plan.  If we were
      unlucky enough to do this at a moment where the path's expansion into
      schema OIDs wasn't already cached, we'd do some catalog accesses; and with
      some more bad luck such as an ill-timed signal arrival, that could lead to
      crashes or Assert failures, as exhibited in bug #8095 from Nachiket Vaidya.
      Fortunately, there's no real need to consider the search path for such
      commands, so we can just skip the relevant steps when the subject statement
      is a TransactionStmt.  This is somewhat related to bug #5269, though the
      failure happens during initial cached-plan creation rather than
      revalidation.
      
      This bug has been there since the plan cache was invented, so back-patch
      to all supported branches.
      c37ec840
  13. Apr 10, 2013
  14. Apr 07, 2013
  15. Apr 05, 2013
  16. Apr 04, 2013
  17. Apr 03, 2013
    • Tom Lane's avatar
      Avoid updating our PgBackendStatus entry when track_activities is off. · a0c2492b
      Tom Lane authored
      The point of turning off track_activities is to avoid this reporting
      overhead, but a thinko in commit 4f42b546
      caused pgstat_report_activity() to perform half of its updates anyway.
      Fix that, and also make sure that we clear all the now-disabled fields
      when transitioning to the non-reporting state.
      a0c2492b
    • Tom Lane's avatar
      Minor robustness improvements for isolationtester. · e084b144
      Tom Lane authored
      Notice and complain about PQcancel() failures.  Also, don't dump core if
      an error PGresult doesn't contain severity and message subfields, as it
      might not if it was generated by libpq itself.  (We have a longstanding
      TODO item to improve that, but in the meantime isolationtester had better
      cope.)
      
      I tripped across the latter item while investigating a trouble report on
      buildfarm member spoonbill.  As for the former, there's no evidence that
      PQcancel failure is actually involved in spoonbill's problem, but it still
      seems like a bad idea to ignore an error return code.
      e084b144
  18. Apr 01, 2013
    • Tom Lane's avatar
      Stamp 9.2.4. · 73c12276
      Tom Lane authored
    • Tom Lane's avatar
      Update release notes for 9.2.4, 9.1.9, 9.0.13, 8.4.17. · 0dfbad83
      Tom Lane authored
      Security: CVE-2013-1899, CVE-2013-1901
      0dfbad83
    • Tom Lane's avatar
      Fix insecure parsing of server command-line switches. · a6e0cd7b
      Tom Lane authored
      An oversight in commit e710b65c allowed
      database names beginning with "-" to be treated as though they were secure
      command-line switches; and this switch processing occurs before client
      authentication, so that even an unprivileged remote attacker could exploit
      the bug, needing only connectivity to the postmaster's port.  Assorted
      exploits for this are possible, some requiring a valid database login,
      some not.  The worst known problem is that the "-r" switch can be invoked
      to redirect the process's stderr output, so that subsequent error messages
      will be appended to any file the server can write.  This can for example be
      used to corrupt the server's configuration files, so that it will fail when
      next restarted.  Complete destruction of database tables is also possible.
      
      Fix by keeping the database name extracted from a startup packet fully
      separate from command-line switches, as had already been done with the
      user name field.
      
      The Postgres project thanks Mitsumasa Kondo for discovering this bug,
      Kyotaro Horiguchi for drafting the fix, and Noah Misch for recognizing
      the full extent of the danger.
      
      Security: CVE-2013-1899
      a6e0cd7b
    • Tom Lane's avatar
      Make REPLICATION privilege checks test current user not authenticated user. · e5fdb8fe
      Tom Lane authored
      The pg_start_backup() and pg_stop_backup() functions checked the privileges
      of the initially-authenticated user rather than the current user, which is
      wrong.  For example, a user-defined index function could successfully call
      these functions when executed by ANALYZE within autovacuum.  This could
      allow an attacker with valid but low-privilege database access to interfere
      with creation of routine backups.  Reported and fixed by Noah Misch.
      
      Security: CVE-2013-1901
      e5fdb8fe
    • Peter Eisentraut's avatar
      Translation updates · fe6b2427
      Peter Eisentraut authored
      fe6b2427
    • Tom Lane's avatar
      Ignore extra subquery outputs in set_subquery_size_estimates(). · 0044f456
      Tom Lane authored
      In commit 0f61d4dd, I added code to copy up
      column width estimates for each column of a subquery.  That code supposed
      that the subquery couldn't have any output columns that didn't correspond
      to known columns of the current query level --- which is true when a query
      is parsed from scratch, but the assumption fails when planning a view that
      depends on another view that's been redefined (adding output columns) since
      the upper view was made.  This results in an assertion failure or even a
      crash, as per bug #8025 from lindebg.  Remove the Assert and instead skip
      the column if its resno is out of the expected range.
      0044f456
  19. Mar 31, 2013
  20. Mar 30, 2013
    • Andrew Dunstan's avatar
      Avoid moving data directory in upgrade testing. · 4e205ec4
      Andrew Dunstan authored
      Windows sometimes gets upset if we rename a large directory and then try
      to use the old name quickly, as seen in occasional buildfarm failures.
      So we avoid that by building the old version in the intended
      destination in the first place instead of renaming it, similar to the
      change made for the same reason in commit b7f8465c.
      4e205ec4
  21. Mar 29, 2013
    • Tom Lane's avatar
      Document encode(bytea, 'escape')'s behavior correctly. · d2b8d060
      Tom Lane authored
      I changed this in commit fd15dba5, but
      missed the fact that the SGML documentation of the function specified
      exactly what it did.  Well, one of the two places where it's specified
      documented that --- probably I looked at the other place and thought
      nothing needed to be done.  Sync the two places where encode() and
      decode() are described.
      d2b8d060
    • Tom Lane's avatar
      Must check indisready not just indisvalid when dumping from 9.2 server. · 723acc99
      Tom Lane authored
      9.2 uses a kluge representation of "indislive"; we have to account for
      that when examining pg_index.  Simplest solution is to check indisready
      for 9.0 and 9.1 as well; that's harmless though unnecessary, so it's
      not worth making a version distinction for.
      
      Fixes oversight in commit 683abc73,
      as noted by Andres Freund.
      723acc99
  22. Mar 28, 2013
  23. Mar 27, 2013
    • Tom Lane's avatar
      Reset OpenSSL randomness state in each postmaster child process. · 21ce40c8
      Tom Lane authored
      Previously, if the postmaster initialized OpenSSL's PRNG (which it will do
      when ssl=on in postgresql.conf), the same pseudo-random state would be
      inherited by each forked child process.  The problem is masked to a
      considerable extent if the incoming connection uses SSL encryption, but
      when it does not, identical pseudo-random state is made available to
      functions like contrib/pgcrypto.  The process's PID does get mixed into any
      requested random output, but on most systems that still only results in 32K
      or so distinct random sequences available across all Postgres sessions.
      This might allow an attacker who has database access to guess the results
      of "secure" operations happening in another session.
      
      To fix, forcibly reset the PRNG after fork().  Each child process that has
      need for random numbers from OpenSSL's generator will thereby be forced to
      go through OpenSSL's normal initialization sequence, which should provide
      much greater variability of the sequences.  There are other ways we might
      do this that would be slightly cheaper, but this approach seems the most
      future-proof against SSL-related code changes.
      
      This has been assigned CVE-2013-1900, but since the issue and the patch
      have already been publicized on pgsql-hackers, there's no point in trying
      to hide this commit.
      
      Back-patch to all supported branches.
      
      Marko Kreen
      21ce40c8
    • Heikki Linnakangas's avatar
      Fix buffer pin leak in heap update redo routine. · 1b315c53
      Heikki Linnakangas authored
      In a heap update, if the old and new tuple were on different pages, and the
      new page no longer existed (because it was subsequently truncated away by
      vacuum), heap_xlog_update forgot to release the pin on the old buffer. This
      bug was introduced by the "Fix multiple problems in WAL replay" patch,
      commit 3bbf668d (on master branch).
      
      With full_page_writes=off, this triggered an "incorrect local pin count"
      error later in replay, if the old page was vacuumed.
      
      This fixes bug #7969, reported by Yunong Xiao. Backpatch to 9.0, like the
      commit that introduced this bug.
      1b315c53
Loading