Skip to content
Snippets Groups Projects
  1. Oct 11, 2011
    • Tom Lane's avatar
      Rearrange the implementation of index-only scans. · a0185461
      Tom Lane authored
      This commit changes index-only scans so that data is read directly from the
      index tuple without first generating a faux heap tuple.  The only immediate
      benefit is that indexes on system columns (such as OID) can be used in
      index-only scans, but this is necessary infrastructure if we are ever to
      support index-only scans on expression indexes.  The executor is now ready
      for that, though the planner still needs substantial work to recognize
      the possibility.
      
      To do this, Vars in index-only plan nodes have to refer to index columns
      not heap columns.  I introduced a new special varno, INDEX_VAR, to mark
      such Vars to avoid confusion.  (In passing, this commit renames the two
      existing special varnos to OUTER_VAR and INNER_VAR.)  This allows
      ruleutils.c to handle them with logic similar to what we use for subplan
      reference Vars.
      
      Since index-only scans are now fundamentally different from regular
      indexscans so far as their expression subtrees are concerned, I also chose
      to change them to have their own plan node type (and hence, their own
      executor source file).
      a0185461
  2. Apr 10, 2011
  3. Mar 26, 2011
  4. Mar 20, 2011
    • Tom Lane's avatar
      Revise collation derivation method and expression-tree representation. · b310b6e3
      Tom Lane authored
      All expression nodes now have an explicit output-collation field, unless
      they are known to only return a noncollatable data type (such as boolean
      or record).  Also, nodes that can invoke collation-aware functions store
      a separate field that is the collation value to pass to the function.
      This avoids confusion that arises when a function has collatable inputs
      and noncollatable output type, or vice versa.
      
      Also, replace the parser's on-the-fly collation assignment method with
      a post-pass over the completed expression tree.  This allows us to use
      a more complex (and hopefully more nearly spec-compliant) assignment
      rule without paying for it in extra storage in every expression node.
      
      Fix assorted bugs in the planner's handling of collations by making
      collation one of the defining properties of an EquivalenceClass and
      by converting CollateExprs into discardable RelabelType nodes during
      expression preprocessing.
      b310b6e3
  5. Mar 11, 2011
    • Tom Lane's avatar
      Split CollateClause into separate raw and analyzed node types. · 8acdb8bf
      Tom Lane authored
      CollateClause is now used only in raw grammar output, and CollateExpr after
      parse analysis.  This is for clarity and to avoid carrying collation names
      in post-analysis parse trees: that's both wasteful and possibly misleading,
      since the collation's name could be changed while the parsetree still
      exists.
      
      Also, clean up assorted infelicities and omissions in processing of the
      node type.
      8acdb8bf
  6. Feb 08, 2011
    • Peter Eisentraut's avatar
      Per-column collation support · 414c5a2e
      Peter Eisentraut authored
      This adds collation support for columns and domains, a COLLATE clause
      to override it per expression, and B-tree index support.
      
      Peter Eisentraut
      reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
      414c5a2e
  7. Jan 01, 2011
  8. Dec 13, 2010
    • Robert Haas's avatar
      Generalize concept of temporary relations to "relation persistence". · 5f7b58fa
      Robert Haas authored
      This commit replaces pg_class.relistemp with pg_class.relpersistence;
      and also modifies the RangeVar node type to carry relpersistence rather
      than istemp.  It also removes removes rd_istemp from RelationData and
      instead performs the correct computation based on relpersistence.
      
      For clarity, we add three new macros: RelationNeedsWAL(),
      RelationUsesLocalBuffers(), and RelationUsesTempNamespace(), so that we
      can clarify the purpose of each check that previous depended on
      rd_istemp.
      
      This is intended as infrastructure for the upcoming unlogged tables
      patch, as well as for future possible work on global temporary tables.
      5f7b58fa
  9. Sep 20, 2010
  10. Jul 12, 2010
    • Tom Lane's avatar
      Make NestLoop plan nodes pass outer-relation variables into their inner · 53e75768
      Tom Lane authored
      relation using the general PARAM_EXEC executor parameter mechanism, rather
      than the ad-hoc kluge of passing the outer tuple down through ExecReScan.
      The previous method was hard to understand and could never be extended to
      handle parameters coming from multiple join levels.  This patch doesn't
      change the set of possible plans nor have any significant performance effect,
      but it's necessary infrastructure for future generalization of the concept
      of an inner indexscan plan.
      
      ExecReScan's second parameter is now unused, so it's removed.
      53e75768
  11. Feb 26, 2010
  12. Feb 17, 2010
  13. Jan 02, 2010
  14. Dec 15, 2009
    • Tom Lane's avatar
      Support ORDER BY within aggregate function calls, at long last providing a · 34d26872
      Tom Lane authored
      non-kluge method for controlling the order in which values are fed to an
      aggregate function.  At the same time eliminate the old implementation
      restriction that DISTINCT was only supported for single-argument aggregates.
      
      Possibly release-notable behavioral change: formerly, agg(DISTINCT x)
      dropped null values of x unconditionally.  Now, it does so only if the
      agg transition function is strict; otherwise nulls are treated as DISTINCT
      normally would, ie, you get one copy.
      
      Andrew Gierth, reviewed by Hitoshi Harada
      34d26872
  15. Oct 08, 2009
  16. Jul 16, 2009
    • Peter Eisentraut's avatar
      Make backend header files C++ safe · de160e2c
      Peter Eisentraut authored
      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
  17. Jun 11, 2009
  18. Apr 05, 2009
    • Tom Lane's avatar
      Change EXPLAIN output so that subplans and initplans (particularly CTEs) · fbcce080
      Tom Lane authored
      are individually labeled, rather than just grouped under an "InitPlan"
      or "SubPlan" heading.  This in turn makes it possible for decompilation of
      a subplan reference to usefully identify which subplan it's referencing.
      I also made InitPlans identify which parameter symbol(s) they compute,
      so that references to those parameters elsewhere in the plan tree can
      be connected to the initplan that will be executed.  Per a gripe from
      Robert Haas about EXPLAIN output of a WITH query being inadequate,
      plus some longstanding pet peeves of my own.
      fbcce080
  19. Mar 10, 2009
    • Tom Lane's avatar
      Make SubPlan nodes carry the result's typmod as well as datatype OID. This is · dcf3902f
      Tom Lane authored
      for consistency with the (relatively) recent addition of typmod to SubLink.
      An example of why it's a good idea is to be seen in the recent "failed to
      locate grouping columns" bug, which wouldn't have happened if a SubPlan
      exposed the same typmod info as the SubLink it was derived from.
      
      This could be back-patched, since it doesn't affect any on-disk data format,
      but for the moment it doesn't seem necessary to do so.
      dcf3902f
  20. Feb 25, 2009
    • Tom Lane's avatar
      Get rid of the rather fuzzily defined FlattenedSubLink node type in favor of · e549722a
      Tom Lane authored
      making pull_up_sublinks() construct a full-blown JoinExpr tree representation
      of IN/EXISTS SubLinks that it is able to convert to semi or anti joins.
      This makes pull_up_sublinks() a shade more complex, but the gain in semantic
      clarity is worth it.  I still have more to do in this area to address the
      previously-discussed problems, but this commit in itself fixes at least one
      bug in HEAD, as shown by added regression test case.
      e549722a
  21. Jan 01, 2009
  22. Dec 28, 2008
  23. Oct 06, 2008
    • Tom Lane's avatar
      When expanding a whole-row Var into a RowExpr during ResolveNew(), attach · bf461538
      Tom Lane authored
      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
  24. Oct 04, 2008
    • Tom Lane's avatar
      Implement SQL-standard WITH clauses, including WITH RECURSIVE. · 44d5be0e
      Tom Lane authored
      There are some unimplemented aspects: recursive queries must use UNION ALL
      (should allow UNION too), and we don't have SEARCH or CYCLE clauses.
      These might or might not get done for 8.4, but even without them it's a
      pretty useful feature.
      
      There are also a couple of small loose ends and definitional quibbles,
      which I'll send a memo about to pgsql-hackers shortly.  But let's land
      the patch now so we can get on with other development.
      
      Yoshiyuki Asaba, with lots of help from Tatsuo Ishii and Tom Lane
      44d5be0e
  25. Sep 01, 2008
  26. Aug 29, 2008
    • Tom Lane's avatar
      Extend the parser location infrastructure to include a location field in · a2794623
      Tom Lane authored
      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
  27. Aug 22, 2008
    • Tom Lane's avatar
      Arrange to convert EXISTS subqueries that are equivalent to hashable IN · bd3dadda
      Tom Lane authored
      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
  28. Aug 02, 2008
    • Tom Lane's avatar
      Rearrange the querytree representation of ORDER BY/GROUP BY/DISTINCT items · 95113047
      Tom Lane authored
      as per my recent proposal:
      
      1. Fold SortClause and GroupClause into a single node type SortGroupClause.
      We were already relying on them to be struct-equivalent, so using two node
      tags wasn't accomplishing much except to get in the way of comparing items
      with equal().
      
      2. Add an "eqop" field to SortGroupClause to carry the associated equality
      operator.  This is cheap for the parser to get at the same time it's looking
      up the sort operator, and storing it eliminates the need for repeated
      not-so-cheap lookups during planning.  In future this will also let us
      represent GROUP/DISTINCT operations on datatypes that have hash opclasses
      but no btree opclasses (ie, they have equality but no natural sort order).
      The previous representation simply didn't work for that, since its only
      indicator of comparison semantics was a sort operator.
      
      3. Add a hasDistinctOn boolean to struct Query to explicitly record whether
      the distinctClause came from DISTINCT or DISTINCT ON.  This allows removing
      some complicated and not 100% bulletproof code that attempted to figure
      that out from the distinctClause alone.
      
      This patch doesn't in itself create any new capability, but it's necessary
      infrastructure for future attempts to use hash-based grouping for DISTINCT
      and UNION/INTERSECT/EXCEPT.
      95113047
  29. Jan 01, 2008
  30. Nov 22, 2007
  31. Nov 15, 2007
  32. Aug 26, 2007
  33. Jun 12, 2007
  34. Jun 11, 2007
    • Tom Lane's avatar
      Support UPDATE/DELETE WHERE CURRENT OF cursor_name, per SQL standard. · 6808f1b1
      Tom Lane authored
      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
  35. Jun 05, 2007
    • Tom Lane's avatar
      Downgrade implicit casts to text to be assignment-only, except for the ones · 31edbadf
      Tom Lane authored
      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
  36. Mar 28, 2007
    • Tom Lane's avatar
      Fix array coercion expressions to ensure that the correct volatility is · bf940763
      Tom Lane authored
      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
  37. Mar 17, 2007
    • Tom Lane's avatar
      Fix up the remaining places where the expression node structure would lose · 0f4ff460
      Tom Lane authored
      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
  38. Feb 22, 2007
    • Tom Lane's avatar
      Turn the rangetable used by the executor into a flat list, and avoid storing · eab6b8b2
      Tom Lane authored
      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
Loading