1. 19 7月, 2011 2 次提交
  2. 18 7月, 2011 1 次提交
    • R
      Create a "fast path" for acquiring weak relation locks. · 3cba8999
      Robert Haas 提交于
      When an AccessShareLock, RowShareLock, or RowExclusiveLock is requested
      on an unshared database relation, and we can verify that no conflicting
      locks can possibly be present, record the lock in a per-backend queue,
      stored within the PGPROC, rather than in the primary lock table.  This
      eliminates a great deal of contention on the lock manager LWLocks.
      
      This patch also refactors the interface between GetLockStatusData() and
      pg_lock_status() to be a bit more abstract, so that we don't rely so
      heavily on the lock manager's internal representation details.  The new
      fast path lock structures don't have a LOCK or PROCLOCK structure to
      return, so we mustn't depend on that for purposes of listing outstanding
      locks.
      
      Review by Jeff Davis.
      3cba8999
  3. 13 7月, 2011 1 次提交
    • T
      Avoid listing ungrouped Vars in the targetlist of Agg-underneath-Window. · c1d9579d
      Tom Lane 提交于
      Regular aggregate functions in combination with, or within the arguments
      of, window functions are OK per spec; they have the semantics that the
      aggregate output rows are computed and then we run the window functions
      over that row set.  (Thus, this combination is not really useful unless
      there's a GROUP BY so that more than one aggregate output row is possible.)
      The case without GROUP BY could fail, as recently reported by Jeff Davis,
      because sloppy construction of the Agg node's targetlist resulted in extra
      references to possibly-ungrouped Vars appearing outside the aggregate
      function calls themselves.  See the added regression test case for an
      example.
      
      Fixing this requires modifying the API of flatten_tlist and its underlying
      function pull_var_clause.  I chose to make pull_var_clause's API for
      aggregates identical to what it was already doing for placeholders, since
      the useful behaviors turn out to be the same (error, report node as-is, or
      recurse into it).  I also tightened the error checking in this area a bit:
      if it was ever valid to see an uplevel Var, Aggref, or PlaceHolderVar here,
      that was a long time ago, so complain instead of ignoring them.
      
      Backpatch into 9.1.  The failure exists in 8.4 and 9.0 as well, but seeing
      that it only occurs in a basically-useless corner case, it doesn't seem
      worth the risks of changing a function API in a minor release.  There might
      be third-party code using pull_var_clause.
      c1d9579d
  4. 08 7月, 2011 1 次提交
  5. 07 7月, 2011 1 次提交
    • H
      Fix a bug with SSI and prepared transactions: · 928408d9
      Heikki Linnakangas 提交于
      If there's a dangerous structure T0 ---> T1 ---> T2, and T2 commits first,
      we need to abort something. If T2 commits before both conflicts appear,
      then it should be caught by OnConflict_CheckForSerializationFailure. If
      both conflicts appear before T2 commits, it should be caught by
      PreCommit_CheckForSerializationFailure. But that is actually run when
      T2 *prepares*. Fix that in OnConflict_CheckForSerializationFailure, by
      treating a prepared T2 as if it committed already.
      
      This is mostly a problem for prepared transactions, which are in prepared
      state for some time, but also for regular transactions because they also go
      through the prepared state in the SSI code for a short moment when they're
      committed.
      
      Kevin Grittner and Dan Ports
      928408d9
  6. 05 7月, 2011 2 次提交
  7. 04 7月, 2011 2 次提交
    • S
      f563afd4
    • R
      Fix bugs in relpersistence handling during table creation. · 5da79169
      Robert Haas 提交于
      Unlike the relistemp field which it replaced, relpersistence must be
      set correctly quite early during the table creation process, as we
      rely on it quite early on for a number of purposes, including security
      checks.  Normally, this is set based on whether the user enters CREATE
      TABLE, CREATE UNLOGGED TABLE, or CREATE TEMPORARY TABLE, but a
      relation may also be made implicitly temporary by creating it in
      pg_temp.  This patch fixes the handling of that case, and also
      disables creation of unlogged tables in temporary tablespace (such
      table indeed skip WAL-logging, but we reject an explicit
      specification) and creation of relations in the temporary schemas of
      other sessions (which is not very sensible, and didn't work right
      anyway).
      
      Report by Amit Khandekar.
      5da79169
  8. 30 6月, 2011 2 次提交
    • A
      Enable CHECK constraints to be declared NOT VALID · 89779524
      Alvaro Herrera 提交于
      This means that they can initially be added to a large existing table
      without checking its initial contents, but new tuples must comply to
      them; a separate pass invoked by ALTER TABLE / VALIDATE can verify
      existing data and ensure it complies with the constraint, at which point
      it is marked validated and becomes a normal part of the table ecosystem.
      
      An non-validated CHECK constraint is ignored in the planner for
      constraint_exclusion purposes; when validated, cached plans are
      recomputed so that partitioning starts working right away.
      
      This patch also enables domains to have unvalidated CHECK constraints
      attached to them as well by way of ALTER DOMAIN / ADD CONSTRAINT / NOT
      VALID, which can later be validated with ALTER DOMAIN / VALIDATE
      CONSTRAINT.
      
      Thanks to Thom Brown, Dean Rasheed and Jaime Casanova for the various
      reviews, and Robert Hass for documentation wording improvement
      suggestions.
      
      This patch was sponsored by Enova Financial.
      89779524
    • T
      Restore correct btree preprocessing of "indexedcol IS NULL" conditions. · a5652d3e
      Tom Lane 提交于
      Such a condition is unsatisfiable in combination with any other type of
      btree-indexable condition (since we assume btree operators are always
      strict).  8.3 and 8.4 had an explicit test for this, which I removed in
      commit 29c4ad98, mistakenly thinking that
      the case would be subsumed by the more general handling of IS (NOT) NULL
      added in that patch.  Put it back, and improve the comments about it, and
      add a regression test case.
      
      Per bug #6079 from Renat Nasyrov, and analysis by Dean Rasheed.
      a5652d3e
  9. 29 6月, 2011 1 次提交
  10. 23 6月, 2011 2 次提交
  11. 22 6月, 2011 3 次提交
  12. 21 6月, 2011 3 次提交
    • H
      Adjust the alternative expected output file for prepared_xacts test case, · 38c0e721
      Heikki Linnakangas 提交于
      used when max_prepared_transactions=0, for the recent changes in the test
      case.
      38c0e721
    • H
      Fix bug in PreCommit_CheckForSerializationFailure. A transaction that has · 1eea8e8a
      Heikki Linnakangas 提交于
      already been marked as PREPARED cannot be killed. Kill the current
      transaction instead.
      
      One of the prepared_xacts regression tests actually hits this bug. I
      removed the anomaly from the duplicate-gids test so that it fails in the
      intended way, and added a new test to check serialization failures with
      a prepared transaction.
      
      Dan Ports
      1eea8e8a
    • T
      Fix thinko in previous patch for optimizing EXISTS-within-EXISTS. · cd1f0d04
      Tom Lane 提交于
      When recursing after an optimization in pull_up_sublinks_qual_recurse, the
      available_rels value passed down must include only the relations that are
      in the righthand side of the new SEMI or ANTI join; it's incorrect to pull
      up a sub-select that refers to other relations, as seen in the added test
      case.  Per report from BangarRaju Vadapalli.
      
      While at it, rethink the idea of recursing below a NOT EXISTS.  That is
      essentially the same situation as pulling up ANY/EXISTS sub-selects that
      are in the ON clause of an outer join, and it has the same disadvantage:
      we'd force the two joins to be evaluated according to the syntactic nesting
      order, because the lower join will most likely not be able to commute with
      the ANTI join.  That could result in having to form a rather large join
      product, whereas the handling of a correlated subselect is not quite that
      dumb.  So until we can handle those cases better, #ifdef NOT_USED that
      case.  (I think it's okay to pull up in the EXISTS/ANY cases, because SEMI
      joins aren't so inflexible about ordering.)
      
      Back-patch to 8.4, same as for previous patch in this area.  Fortunately
      that patch hadn't made it into any shipped releases yet.
      cd1f0d04
  13. 19 6月, 2011 1 次提交
  14. 10 6月, 2011 1 次提交
  15. 09 6月, 2011 1 次提交
    • T
      Allow domains over arrays to match ANYARRAY parameters again. · b7e8feb3
      Tom Lane 提交于
      This use-case was broken in commit 529cb267
      of 2010-10-21, in which I commented "For the moment, we just forbid such
      matching.  We might later wish to insert an automatic downcast to the
      underlying array type, but such a change should also change matching of
      domains to ANYELEMENT for consistency".  We still lack consensus about what
      to do with ANYELEMENT; but not matching ANYARRAY is a clear loss of
      functionality compared to prior releases, so let's go ahead and make that
      happen.  Per complaint from Regina Obe and extensive subsequent discussion.
      b7e8feb3
  16. 07 6月, 2011 1 次提交
    • T
      Fix rewriter to cope (more or less) with CTEs in the query being rewritten. · fc1286d3
      Tom Lane 提交于
      Since the original implementation of CTEs only allowed them in SELECT
      queries, the rule rewriter did not expect to find any CTEs in statements
      being rewritten by ON INSERT/UPDATE/DELETE rules.  We had dealt with this
      to some extent but the code was still several bricks shy of a load, as
      illustrated in bug #6051 from Jehan-Guillaume de Rorthais.
      
      In particular, we have to be able to copy CTEs from the original query's
      cteList into that of a rule action, in case the rule action references the
      CTE (which it pretty much always will).  This also implies we were doing
      things in the wrong order in RewriteQuery: we have to recursively rewrite
      the CTE queries before expanding the main query, so that we have the
      rewritten queries available to copy.
      
      There are unpleasant limitations yet to resolve here, but at least we now
      throw understandable FEATURE_NOT_SUPPORTED errors for them instead of just
      failing with bizarre implementation-dependent errors.  In particular, we
      can't handle propagating the same CTE into multiple post-rewrite queries
      (because then the CTE would be evaluated multiple times), and we can't cope
      with conflicts between CTE names in the original query and in the rule
      actions.
      fc1286d3
  17. 06 6月, 2011 1 次提交
  18. 04 6月, 2011 1 次提交
    • T
      Fix failure to check whether a rowtype's component types are sortable. · ea8e42f3
      Tom Lane 提交于
      The existence of a btree opclass accepting composite types caused us to
      assume that every composite type is sortable.  This isn't true of course;
      we need to check if the column types are all sortable.  There was logic
      for this for the case of array comparison (ie, check that the element
      type is sortable), but we missed the point for rowtypes.  Per Teodor's
      report of an ANALYZE failure for an unsortable composite type.
      
      Rather than just add some more ad-hoc logic for this, I moved knowledge of
      the issue into typcache.c.  The typcache will now only report out array_eq,
      record_cmp, and friends as usable operators if the array or composite type
      will work with those functions.
      
      Unfortunately we don't have enough info to do this for anonymous RECORD
      types; in that case, just assume it will work, and take the runtime failure
      as before if it doesn't.
      
      This patch might be a candidate for back-patching at some point, but
      given the lack of complaints from the field, I'd rather just test it in
      HEAD for now.
      
      Note: most of the places touched in this patch will need further work
      when we get around to supporting hashing of record types.
      ea8e42f3
  19. 03 6月, 2011 1 次提交
    • T
      Handle domains when checking for recursive inclusion of composite types. · aff97b1f
      Tom Lane 提交于
      We need this now because we allow domains over arrays, and we'll probably
      allow domains over composites pretty soon, which makes the problem even
      more obvious.
      
      Although domains over arrays also exist in previous versions, this does not
      need to be back-patched, because the coding used in older versions
      successfully "looked through" domains over arrays.  The problem is exposed
      by not treating a domain as having a typelem.
      
      Problem identified by Noah Misch, though I did not use his patch, since
      it would require additional work to handle domains over composites that
      way.  This approach is more future-proof.
      aff97b1f
  20. 21 5月, 2011 2 次提交
  21. 19 5月, 2011 1 次提交
  22. 16 5月, 2011 1 次提交
  23. 06 5月, 2011 1 次提交
  24. 28 4月, 2011 1 次提交
  25. 26 4月, 2011 3 次提交
  26. 25 4月, 2011 1 次提交
  27. 24 4月, 2011 2 次提交
    • T
      Improve findoidjoins to cover more cases. · 795c382e
      Tom Lane 提交于
      Teach the program and script to deal with OID-array referencing columns,
      which we now have several of.  Also, modify the recommended usage process
      to specify that the program should be run against the regression database
      rather than template1.  This lets it find numerous joins that cannot be
      found in template1 because the relevant catalogs are entirely empty.
      
      Together these changes add seventeen formerly-missed cases to the oidjoins
      regression test.
      795c382e
    • T
      970d8a39