1. 16 1月, 2003 1 次提交
    • T
      Allow merge and hash joins to occur on arbitrary expressions (anything not · de97072e
      Tom Lane 提交于
      containing a volatile function), rather than only on 'Var = Var' clauses
      as before.  This makes it practical to do flatten_join_alias_vars at the
      start of planning, which in turn eliminates a bunch of klugery inside the
      planner to deal with alias vars.  As a free side effect, we now detect
      implied equality of non-Var expressions; for example in
      	SELECT ... WHERE a.x = b.y and b.y = 42
      we will deduce a.x = 42 and use that as a restriction qual on a.  Also,
      we can remove the restriction introduced 12/5/02 to prevent pullup of
      subqueries whose targetlists contain sublinks.
      Still TODO: make statistical estimation routines in selfuncs.c and costsize.c
      smarter about expressions that are more complex than plain Vars.  The need
      for this is considerably greater now that we have to be able to estimate
      the suitability of merge and hash join techniques on such expressions.
      de97072e
  2. 13 1月, 2003 1 次提交
  3. 05 1月, 2003 1 次提交
  4. 14 12月, 2002 1 次提交
    • T
      Clean up plantree representation of SubPlan-s --- SubLink does not appear · 2d8d6662
      Tom Lane 提交于
      in the planned representation of a subplan at all any more, only SubPlan.
      This means subselect.c doesn't scribble on its input anymore, which seems
      like a good thing; and there are no longer three different possible
      interpretations of a SubLink.  Simplify node naming and improve comments
      in primnodes.h.  No change to stored rules, though.
      2d8d6662
  5. 12 12月, 2002 1 次提交
    • T
      Phase 2 of read-only-plans project: restructure expression-tree nodes · a0bf885f
      Tom Lane 提交于
      so that all executable expression nodes inherit from a common supertype
      Expr.  This is somewhat of an exercise in code purity rather than any
      real functional advance, but getting rid of the extra Oper or Func node
      formerly used in each operator or function call should provide at least
      a little space and speed improvement.
      initdb forced by changes in stored-rules representation.
      a0bf885f
  6. 26 11月, 2002 1 次提交
  7. 19 9月, 2002 1 次提交
    • T
      Extend pg_cast castimplicit column to a three-way value; this allows us · b26dfb95
      Tom Lane 提交于
      to be flexible about assignment casts without introducing ambiguity in
      operator/function resolution.  Introduce a well-defined promotion hierarchy
      for numeric datatypes (int2->int4->int8->numeric->float4->float8).
      Change make_const to initially label numeric literals as int4, int8, or
      numeric (never float8 anymore).
      Explicitly mark Func and RelabelType nodes to indicate whether they came
      from a function call, explicit cast, or implicit cast; use this to do
      reverse-listing more accurately and without so many heuristics.
      Explicit casts to char, varchar, bit, varbit will truncate or pad without
      raising an error (the pre-7.2 behavior), while assigning to a column without
      any explicit cast will still raise an error for wrong-length data like 7.3.
      This more nearly follows the SQL spec than 7.2 behavior (we should be
      reporting a 'completion condition' in the explicit-cast cases, but we have
      no mechanism for that, so just do silent truncation).
      Fix some problems with enforcement of typmod for array elements;
      it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
      Provide a generalized array_length_coerce() function to replace the
      specialized per-array-type functions that used to be needed (and were
      missing for NUMERIC as well as all the datetime types).
      Add missing conversions int8<->float4, text<->numeric, oid<->int8.
      initdb forced.
      b26dfb95
  8. 11 9月, 2002 1 次提交
    • T
      Tweak querytree-dependency-extraction code so that columns of tables · 6fdc44be
      Tom Lane 提交于
      that are explicitly JOINed are not considered dependencies unless they
      are actually used in the query: mere presence in the joinaliasvars
      list of a JOIN RTE doesn't count as being used.  The patch touches
      a number of files because I needed to generalize the API of
      query_tree_walker to support an additional flag bit, but the changes
      are otherwise quite small.
      6fdc44be
  9. 05 9月, 2002 1 次提交
  10. 02 9月, 2002 1 次提交
  11. 30 8月, 2002 1 次提交
  12. 03 8月, 2002 1 次提交
    • T
      ALTER TABLE DROP COLUMN works. Patch by Christopher Kings-Lynne, · 38bb77a5
      Tom Lane 提交于
      code review by Tom Lane.  Remaining issues: functions that take or
      return tuple types are likely to break if one drops (or adds!)
      a column in the table defining the type.  Need to think about what
      to do here.
      
      Along the way: some code review for recent COPY changes; mark system
      columns attnotnull = true where appropriate, per discussion a month ago.
      38bb77a5
  13. 21 6月, 2002 1 次提交
  14. 22 3月, 2002 1 次提交
    • T
      A little further progress on schemas: push down RangeVars into · 108a0ec8
      Tom Lane 提交于
      addRangeTableEntry calls.  Remove relname field from RTEs, since
      it will no longer be a useful unique identifier of relations;
      we want to encourage people to rely on the relation OID instead.
      Further work on dumping qual expressions in EXPLAIN, too.
      108a0ec8
  15. 12 3月, 2002 1 次提交
    • T
      Restructure representation of join alias variables. An explicit JOIN · 6eeb95f0
      Tom Lane 提交于
      now has an RTE of its own, and references to its outputs now are Vars
      referencing the JOIN RTE, rather than CASE-expressions.  This allows
      reverse-listing in ruleutils.c to use the correct alias easily, rather
      than painfully reverse-engineering the alias namespace as it used to do.
      Also, nested FULL JOINs work correctly, because the result of the inner
      joins are simple Vars that the planner can cope with.  This fixes a bug
      reported a couple times now, notably by Tatsuo on 18-Nov-01.  The alias
      Vars are expanded into COALESCE expressions where needed at the very end
      of planning, rather than during parsing.
      Also, beginnings of support for showing plan qualifier expressions in
      EXPLAIN.  There are probably still cases that need work.
      initdb forced due to change of stored-rule representation.
      6eeb95f0
  16. 05 3月, 2002 1 次提交
  17. 01 3月, 2002 1 次提交
  18. 13 11月, 2001 1 次提交
  19. 28 10月, 2001 1 次提交
  20. 25 10月, 2001 1 次提交
  21. 15 8月, 2001 1 次提交
  22. 05 6月, 2001 1 次提交
    • T
      Further work on making use of new statistics in planner. Adjust APIs · 7c579fa1
      Tom Lane 提交于
      of costsize.c routines to pass Query root, so that costsize can figure
      more things out by itself and not be so dependent on its callers to tell
      it everything it needs to know.  Use selectivity of hash or merge clause
      to estimate number of tuples processed internally in these joins
      (this is more useful than it would've been before, since eqjoinsel is
      somewhat more accurate than before).
      7c579fa1
  23. 21 5月, 2001 1 次提交
    • T
      Modify optimizer data structures so that IndexOptInfo lists built for · be03eb25
      Tom Lane 提交于
      create_index_paths are not immediately discarded, but are available for
      subsequent planner work.  This allows avoiding redundant syscache lookups
      in several places.  Change interface to operator selectivity estimation
      procedures to allow faster and more flexible estimation.
      Initdb forced due to change of pg_proc entries for selectivity functions!
      be03eb25
  24. 07 5月, 2001 1 次提交
    • T
      Rewrite of planner statistics-gathering code. ANALYZE is now available as · f905d65e
      Tom Lane 提交于
      a separate statement (though it can still be invoked as part of VACUUM, too).
      pg_statistic redesigned to be more flexible about what statistics are
      stored.  ANALYZE now collects a list of several of the most common values,
      not just one, plus a histogram (not just the min and max values).  Random
      sampling is used to make the process reasonably fast even on very large
      tables.  The number of values and histogram bins collected is now
      user-settable via an ALTER TABLE command.
      
      There is more still to do; the new stats are not being used everywhere
      they could be in the planner.  But the remaining changes for this project
      should be localized, and the behavior is already better than before.
      
      A not-very-related change is that sorting now makes use of btree comparison
      routines if it can find one, rather than invoking '<' twice.
      f905d65e
  25. 28 3月, 2001 1 次提交
  26. 22 3月, 2001 1 次提交
  27. 25 1月, 2001 1 次提交
  28. 18 1月, 2001 1 次提交
  29. 15 12月, 2000 1 次提交
    • T
      Planner speedup hacking. Avoid saving useless pathkeys, so that path · ea166f11
      Tom Lane 提交于
      comparison does not consider paths different when they differ only in
      uninteresting aspects of sort order.  (We had a special case of this
      consideration for indexscans already, but generalize it to apply to
      ordered join paths too.)  Be stricter about what is a canonical pathkey
      to allow faster pathkey comparison.  Cache canonical pathkeys and
      dispersion stats for left and right sides of a RestrictInfo's clause,
      to avoid repeated computation.  Total speedup will depend on number of
      tables in a query, but I see about 4x speedup of planning phase for
      a sample seven-table query.
      ea166f11
  30. 13 12月, 2000 1 次提交
  31. 12 11月, 2000 1 次提交
    • T
      Restructure handling of inheritance queries so that they work with outer · 6543d81d
      Tom Lane 提交于
      joins, and clean things up a good deal at the same time.  Append plan node
      no longer hacks on rangetable at runtime --- instead, all child tables are
      given their own RT entries during planning.  Concept of multiple target
      tables pushed up into execMain, replacing bug-prone implementation within
      nodeAppend.  Planner now supports generating Append plans for inheritance
      sets either at the top of the plan (the old way) or at the bottom.  Expanding
      at the bottom is appropriate for tables used as sources, since they may
      appear inside an outer join; but we must still expand at the top when the
      target of an UPDATE or DELETE is an inheritance set, because we actually need
      a different targetlist and junkfilter for each target table in that case.
      Fortunately a target table can't be inside an outer join...  Bizarre mutual
      recursion between union_planner and prepunion.c is gone --- in fact,
      union_planner doesn't really have much to do with union queries anymore,
      so I renamed it grouping_planner.
      6543d81d
  32. 09 11月, 2000 1 次提交
  33. 06 10月, 2000 1 次提交
    • T
      Reimplementation of UNION/INTERSECT/EXCEPT. INTERSECT/EXCEPT now meet the · 05e3d0ee
      Tom Lane 提交于
      SQL92 semantics, including support for ALL option.  All three can be used
      in subqueries and views.  DISTINCT and ORDER BY work now in views, too.
      This rewrite fixes many problems with cross-datatype UNIONs and INSERT/SELECT
      where the SELECT yields different datatypes than the INSERT needs.  I did
      that by making UNION subqueries and SELECT in INSERT be treated like
      subselects-in-FROM, thereby allowing an extra level of targetlist where the
      datatype conversions can be inserted safely.
      INITDB NEEDED!
      05e3d0ee
  34. 30 9月, 2000 1 次提交
    • T
      Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias. · 3a94e789
      Tom Lane 提交于
      (Don't forget that an alias is required.)  Views reimplemented as expanding
      to subselect-in-FROM.  Grouping, aggregates, DISTINCT in views actually
      work now (he says optimistically).  No UNION support in subselects/views
      yet, but I have some ideas about that.  Rule-related permissions checking
      moved out of rewriter and into executor.
      INITDB REQUIRED!
      3a94e789
  35. 13 9月, 2000 1 次提交
  36. 20 6月, 2000 1 次提交
  37. 30 5月, 2000 1 次提交
  38. 18 4月, 2000 1 次提交
  39. 13 4月, 2000 1 次提交
  40. 21 3月, 2000 1 次提交
    • T
      Restructure planning code so that preprocessing of targetlist and quals · 3ee8f7e2
      Tom Lane 提交于
      to simplify constant expressions and expand SubLink nodes into SubPlans
      is done in a separate routine subquery_planner() that calls union_planner().
      We formerly did most of this work in query_planner(), but that's the
      wrong place because it may never see the real targetlist.  Splitting
      union_planner into two routines also allows us to avoid redundant work
      when union_planner is invoked recursively for UNION and inheritance
      cases.  Upshot is that it is now possible to do something like
      select float8(count(*)) / (select count(*) from int4_tbl)  from int4_tbl
      group by f1;
      which has never worked before.
      3ee8f7e2