1. 09 11月, 2009 1 次提交
  2. 31 10月, 2009 1 次提交
    • T
      Implement parser hooks for processing ColumnRef and ParamRef nodes, as per my · fb5d0580
      Tom Lane 提交于
      recent proposal.  As proof of concept, remove knowledge of Params from the
      core parser, arranging for them to be handled entirely by parser hook
      functions.  It turns out we need an additional hook for that --- I had
      forgotten about the code that handles inferring a parameter's type from
      context.
      
      This is a preliminary step towards letting plpgsql handle its variables
      through parser hooks.  Additional work remains to be done to expose the
      facility through SPI, but I think this is all the changes needed in the core
      parser.
      fb5d0580
  3. 28 10月, 2009 1 次提交
    • T
      Make FOR UPDATE/SHARE in the primary query not propagate into WITH queries; · 61e53282
      Tom Lane 提交于
      for example in
        WITH w AS (SELECT * FROM foo) SELECT * FROM w, bar ... FOR UPDATE
      the FOR UPDATE will now affect bar but not foo.  This is more useful and
      consistent than the original 8.4 behavior, which tried to propagate FOR UPDATE
      into the WITH query but always failed due to assorted implementation
      restrictions.  Even though we are in process of removing those restrictions,
      it seems correct on philosophical grounds to not let the outer query's
      FOR UPDATE affect the WITH query.
      
      In passing, fix isLockedRel which frequently got things wrong in
      nested-subquery cases: "FOR UPDATE OF foo" applies to an alias foo in the
      current query level, not subqueries.  This has been broken for a long time,
      but it doesn't seem worth back-patching further than 8.4 because the actual
      consequences are minimal.  At worst the parser would sometimes get
      RowShareLock on a relation when it should be AccessShareLock or vice versa.
      That would only make a difference if someone were using ExclusiveLock
      concurrently, which no standard operation does, and anyway FOR UPDATE
      doesn't result in visible changes so it's not clear that the someone would
      notice any problem.  Between that and the fact that FOR UPDATE barely works
      with subqueries at all in existing releases, I'm not excited about worrying
      about it.
      61e53282
  4. 22 10月, 2009 1 次提交
  5. 08 10月, 2009 1 次提交
  6. 09 9月, 2009 1 次提交
    • T
      Fix bug with WITH RECURSIVE immediately inside WITH RECURSIVE. 99% of the · 255f66ef
      Tom Lane 提交于
      code was already okay with this, but the hack that obtained the output
      column types of a recursive union in advance of doing real parse analysis
      of the recursive union forgot to handle the case where there was an inner
      WITH clause available to the non-recursive term.  Best fix seems to be to
      refactor so that we don't need the "throwaway" parse analysis step at all.
      Instead, teach the transformSetOperationStmt code to set up the CTE's output
      column information after it's processed the non-recursive term normally.
      Per report from David Fetter.
      255f66ef
  7. 16 7月, 2009 1 次提交
    • P
      Make backend header files C++ safe · de160e2c
      Peter Eisentraut 提交于
      This alters various incidental uses of C++ key words to use other similar
      identifiers, so that a C++ compiler won't choke outright.  You still
      (probably) need extern "C" { }; around the inclusion of backend headers.
      
      based on a patch by Kurt Harriman <harriman@acm.org>
      
      Also add a script cpluspluscheck to check for C++ compatibility in the
      future.  As of right now, this passes without error for me.
      de160e2c
  8. 11 6月, 2009 1 次提交
  9. 23 1月, 2009 1 次提交
  10. 02 1月, 2009 1 次提交
  11. 29 12月, 2008 1 次提交
  12. 26 10月, 2008 2 次提交
    • T
      Better solution to the IN-list issue: instead of having an arbitrary cutoff, · 0aed62fe
      Tom Lane 提交于
      treat Var and non-Var IN-list items differently.  Only non-Var items are
      candidates to go into an ANY(ARRAY) construct --- we put all Vars as separate
      OR conditions on the grounds that that leaves more scope for optimization.
      Per suggestion from Robert Haas.
      0aed62fe
    • T
      Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)" · ddbe8dca
      Tom Lane 提交于
      into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there
      are Vars in the right-hand side.  This avoids a performance regression compared
      to pre-8.2 releases, in cases where the OR form can be optimized into scans
      of multiple indexes.  Limit the possible downside by preferring this form only
      when the list isn't very long (I set the cutoff at 32 elements, which is a
      bit arbitrary but in the right ballpark).  Per discussion with Jim Nasby.
      
      In passing, also make it try the OR form if it cannot select a common type
      for the array elements; we've seen a complaint or two about how the OR form
      worked for such cases and ARRAY doesn't.
      ddbe8dca
  13. 07 10月, 2008 1 次提交
    • T
      When expanding a whole-row Var into a RowExpr during ResolveNew(), attach · bf461538
      Tom Lane 提交于
      the column alias names of the RTE referenced by the Var to the RowExpr.
      This is needed to allow ruleutils.c to correctly deparse FieldSelect nodes
      referencing such a construct.  Per my recent bug report.
      
      Adding a field to RowExpr forces initdb (because of stored rules changes)
      so this solution is not back-patchable; which is unfortunate because 8.2
      and 8.3 have this issue.  But it only affects EXPLAIN for some pretty odd
      corner cases, so we can probably live without a solution for the back
      branches.
      bf461538
  14. 02 9月, 2008 1 次提交
  15. 30 8月, 2008 1 次提交
  16. 29 8月, 2008 1 次提交
    • T
      Extend the parser location infrastructure to include a location field in · a2794623
      Tom Lane 提交于
      most node types used in expression trees (both before and after parse
      analysis).  This allows us to place an error cursor in many situations
      where we formerly could not, because the information wasn't available
      beyond the very first level of parse analysis.  There's a fair amount
      of work still to be done to persuade individual ereport() calls to actually
      include an error location, but this gets the initdb-forcing part of the
      work out of the way; and the situation is already markedly better than
      before for complaints about unimplementable implicit casts, such as
      CASE and UNION constructs with incompatible alternative data types.
      Per my proposal of a few days ago.
      a2794623
  17. 26 8月, 2008 1 次提交
  18. 22 8月, 2008 1 次提交
    • T
      Arrange to convert EXISTS subqueries that are equivalent to hashable IN · bd3dadda
      Tom Lane 提交于
      subqueries into the same thing you'd have gotten from IN (except always with
      unknownEqFalse = true, so as to get the proper semantics for an EXISTS).
      I believe this fixes the last case within CVS HEAD in which an EXISTS could
      give worse performance than an equivalent IN subquery.
      
      The tricky part of this is that if the upper query probes the EXISTS for only
      a few rows, the hashing implementation can actually be worse than the default,
      and therefore we need to make a cost-based decision about which way to use.
      But at the time when the planner generates plans for subqueries, it doesn't
      really know how many times the subquery will be executed.  The least invasive
      solution seems to be to generate both plans and postpone the choice until
      execution.  Therefore, in a query that has been optimized this way, EXPLAIN
      will show two subplans for the EXISTS, of which only one will actually get
      executed.
      
      There is a lot more that could be done based on this infrastructure: in
      particular it's interesting to consider switching to the hash plan if we start
      out using the non-hashed plan but find a lot more upper rows going by than we
      expected.  I have therefore left some minor inefficiencies in place, such as
      initializing both subplans even though we will currently only use one.
      bd3dadda
  19. 16 7月, 2008 1 次提交
    • T
      Support "variadic" functions, which can accept a variable number of arguments · d89737d3
      Tom Lane 提交于
      so long as all the trailing arguments are of the same (non-array) type.
      The function receives them as a single array argument (which is why they
      have to all be the same type).
      
      It might be useful to extend this facility to aggregates, but this patch
      doesn't do that.
      
      This patch imposes a noticeable slowdown on function lookup --- a follow-on
      patch will fix that by adding a redundant column to pg_proc.
      
      Pavel Stehule
      d89737d3
  20. 29 4月, 2008 1 次提交
  21. 21 3月, 2008 1 次提交
    • T
      Arrange for an explicit cast applied to an ARRAY[] constructor to be applied · 6b0706ac
      Tom Lane 提交于
      directly to all the member expressions, instead of the previous implementation
      where the ARRAY[] constructor would infer a common element type and then we'd
      coerce the finished array after the fact.  This has a number of benefits,
      one being that we can allow an empty ARRAY[] construct so long as its
      element type is specified by such a cast.
      
      Brendan Jurd, minor fixes by me.
      6b0706ac
  22. 02 1月, 2008 1 次提交
  23. 16 11月, 2007 2 次提交
  24. 12 11月, 2007 1 次提交
    • T
      Ensure that typmod decoration on a datatype name is validated in all cases, · 0bd4da23
      Tom Lane 提交于
      even in code paths where we don't pay any subsequent attention to the typmod
      value.  This seems needed in view of the fact that 8.3's generalized typmod
      support will accept a lot of bogus syntax, such as "timestamp(foo)" or
      "record(int, 42)" --- if we allow such things to pass without comment,
      users will get confused.  Per a recent example from Greg Stark.
      
      To implement this in a way that's not very vulnerable to future
      bugs-of-omission, refactor the API of parse_type.c's TypeName lookup routines
      so that typmod validation is folded into the base lookup operation.  Callers
      can still choose not to receive the encoded typmod, but we'll check the
      decoration anyway if it's present.
      0bd4da23
  25. 30 10月, 2007 1 次提交
    • T
      Remove the hack in the grammar that "optimized away" DEFAULT NULL clauses. · b17b7fae
      Tom Lane 提交于
      Instead put in a test to drop a NULL default at the last moment before
      storing the catalog entry.  This changes the behavior in a couple of ways:
      * Specifying DEFAULT NULL when creating an inheritance child table will
        successfully suppress inheritance of any default expression from the
        parent's column, where formerly it failed to do so.
      * Specifying DEFAULT NULL for a column of a domain type will correctly
        override any default belonging to the domain; likewise for a sub-domain.
      The latter change happens because by the time the clause is checked,
      it won't be a simple null Const but a CoerceToDomain expression.
      
      Personally I think this should be back-patched, but there doesn't seem to
      be consensus for that on pgsql-hackers, so refraining.
      b17b7fae
  26. 24 6月, 2007 1 次提交
    • T
      Separate parse-analysis for utility commands out of parser/analyze.c · 46379d6e
      Tom Lane 提交于
      (which now deals only in optimizable statements), and put that code
      into a new file parser/parse_utilcmd.c.  This helps clarify and enforce
      the design rule that utility statements shouldn't be processed during
      the regular parse analysis phase; all interpretation of their meaning
      should happen after they are given to ProcessUtility to execute.
      (We need this because we don't retain any locks for a utility statement
      that's in a plan cache, nor have any way to detect that it's stale.)
      
      We are also able to simplify the API for parse_analyze() and related
      routines, because they will now always return exactly one Query structure.
      
      In passing, fix bug #3403 concerning trying to add a serial column to
      an existing temp table (this is largely Heikki's work, but we needed
      all that restructuring to make it safe).
      46379d6e
  27. 12 6月, 2007 1 次提交
  28. 11 6月, 2007 1 次提交
    • T
      Support UPDATE/DELETE WHERE CURRENT OF cursor_name, per SQL standard. · 6808f1b1
      Tom Lane 提交于
      Along the way, allow FOR UPDATE in non-WITH-HOLD cursors; there may once
      have been a reason to disallow that, but it seems to work now, and it's
      really rather necessary if you want to select a row via a cursor and then
      update it in a concurrent-safe fashion.
      
      Original patch by Arul Shaji, rather heavily editorialized by Tom Lane.
      6808f1b1
  29. 06 6月, 2007 1 次提交
    • T
      Downgrade implicit casts to text to be assignment-only, except for the ones · 31edbadf
      Tom Lane 提交于
      from the other string-category types; this eliminates a lot of surprising
      interpretations that the parser could formerly make when there was no directly
      applicable operator.
      
      Create a general mechanism that supports casts to and from the standard string
      types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's
      I/O functions.  These new casts are assignment-only in the to-string direction,
      explicit-only in the other, and therefore should create no surprising behavior.
      Remove a bunch of thereby-obsoleted datatype-specific casting functions.
      
      The "general mechanism" is a new expression node type CoerceViaIO that can
      actually convert between *any* two datatypes if their external text
      representations are compatible.  This is more general than needed for the
      immediate feature, but might be useful in plpgsql or other places in future.
      
      This commit does nothing about the issue that applying the concatenation
      operator || to non-text types will now fail, often with strange error messages
      due to misinterpreting the operator as array concatenation.  Since it often
      (not always) worked before, we should either make it succeed or at least give
      a more user-friendly error; but details are still under debate.
      
      Peter Eisentraut and Tom Lane
      31edbadf
  30. 28 4月, 2007 1 次提交
    • T
      Modify processing of DECLARE CURSOR and EXPLAIN so that they can resolve the · bbbe825f
      Tom Lane 提交于
      types of unspecified parameters when submitted via extended query protocol.
      This worked in 8.2 but I had broken it during plancache changes.  DECLARE
      CURSOR is now treated almost exactly like a plain SELECT through parse
      analysis, rewrite, and planning; only just before sending to the executor
      do we divert it away to ProcessUtility.  This requires a special-case check
      in a number of places, but practically all of them were already special-casing
      SELECT INTO, so it's not too ugly.  (Maybe it would be a good idea to merge
      the two by treating IntoClause as a form of utility statement?  Not going to
      worry about that now, though.)  That approach doesn't work for EXPLAIN,
      however, so for that I punted and used a klugy solution of running parse
      analysis an extra time if under extended query protocol.
      bbbe825f
  31. 02 4月, 2007 1 次提交
  32. 28 3月, 2007 1 次提交
    • T
      Fix array coercion expressions to ensure that the correct volatility is · bf940763
      Tom Lane 提交于
      seen by code inspecting the expression.  The best way to do this seems
      to be to drop the original representation as a function invocation, and
      instead make a special expression node type that represents applying
      the element-type coercion function to each array element.  In this way
      the element function is exposed and will be checked for volatility.
      Per report from Guillaume Smet.
      bf940763
  33. 17 3月, 2007 2 次提交
    • T
      Ooops, got only one of the two ArrayExpr variants correct in first · e88a7ad7
      Tom Lane 提交于
      cut at exprTypmod support.  Also, experimentation shows that we need
      to label the type of Const nodes that are numeric with a specific
      typmod.
      e88a7ad7
    • T
      Fix up the remaining places where the expression node structure would lose · 0f4ff460
      Tom Lane 提交于
      available information about the typmod of an expression; namely, Const,
      ArrayRef, ArrayExpr, and EXPR and ARRAY SubLinks.  In the ArrayExpr and
      SubLink cases it wasn't really the data structure's fault, but exprTypmod()
      being lazy.  This seems like a good idea in view of the expected increase in
      typmod usage from Teodor's work to allow user-defined types to have typmods.
      In particular this responds to the concerns we had about eliminating the
      special-purpose hack that exprTypmod() used to have for BPCHAR Consts.
      We can now tell whether or not such a Const has been cast to a specific
      length, and report or display properly if so.
      
      initdb forced due to changes in stored rules.
      0f4ff460
  34. 23 2月, 2007 1 次提交
    • T
      Turn the rangetable used by the executor into a flat list, and avoid storing · eab6b8b2
      Tom Lane 提交于
      useless substructure for its RangeTblEntry nodes.  (I chose to keep using the
      same struct node type and just zero out the link fields for unneeded info,
      rather than making a separate ExecRangeTblEntry type --- it seemed too
      fragile to have two different rangetable representations.)
      
      Along the way, put subplans into a list in the toplevel PlannedStmt node,
      and have SubPlan nodes refer to them by list index instead of direct pointers.
      Vadim wanted to do that years ago, but I never understood what he was on about
      until now.  It makes things a *whole* lot more robust, because we can stop
      worrying about duplicate processing of subplans during expression tree
      traversals.  That's been a constant source of bugs, and it's finally gone.
      
      There are some consequent simplifications yet to be made, like not using
      a separate EState for subplans in the executor, but I'll tackle that later.
      eab6b8b2
  35. 12 2月, 2007 1 次提交
  36. 03 2月, 2007 1 次提交
  37. 25 1月, 2007 1 次提交
    • P
      Various fixes in the logic of XML functions: · 22bd156f
      Peter Eisentraut 提交于
      - Add new SQL command SET XML OPTION (also available via regular GUC) to
        control the DOCUMENT vs. CONTENT option in implicit parsing and
        serialization operations.
      
      - Subtle corrections in the handling of the standalone property in
        xmlroot().
      
      - Allow xmlroot() to work on content fragments.
      
      - Subtle corrections in the handling of the version property in
        xmlconcat().
      
      - Code refactoring for producing XML declarations.
      22bd156f