1. 04 8月, 2008 1 次提交
  2. 03 8月, 2008 1 次提交
    • T
      Rearrange the querytree representation of ORDER BY/GROUP BY/DISTINCT items · 95113047
      Tom Lane 提交于
      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
  3. 01 8月, 2008 1 次提交
    • T
      Fix parser so that we don't modify the user-written ORDER BY list in order · 63247bec
      Tom Lane 提交于
      to represent DISTINCT or DISTINCT ON.  This gets rid of a longstanding
      annoyance that a view or rule using SELECT DISTINCT will be dumped out
      with an overspecified ORDER BY list, and is one small step along the way
      to decoupling DISTINCT and ORDER BY enough so that hash-based implementation
      of DISTINCT will be possible.  In passing, improve transformDistinctClause
      so that it doesn't reject duplicate DISTINCT ON items, as was reported by
      Steve Midgley a couple weeks ago.
      63247bec
  4. 19 6月, 2008 1 次提交
  5. 16 2月, 2008 1 次提交
  6. 02 1月, 2008 1 次提交
  7. 16 11月, 2007 1 次提交
  8. 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
  9. 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
  10. 02 2月, 2007 1 次提交
    • B
      Wording cleanup for error messages. Also change can't -> cannot. · 8b4ff8b6
      Bruce Momjian 提交于
      Standard English uses "may", "can", and "might" in different ways:
      
              may - permission, "You may borrow my rake."
      
              can - ability, "I can lift that log."
      
              might - possibility, "It might rain today."
      
      Unfortunately, in conversational English, their use is often mixed, as
      in, "You may use this variable to do X", when in fact, "can" is a better
      choice.  Similarly, "It may crash" is better stated, "It might crash".
      8b4ff8b6
  11. 11 1月, 2007 1 次提交
    • T
      Change the planner-to-executor API so that the planner tells the executor · a191a169
      Tom Lane 提交于
      which comparison operators to use for plan nodes involving tuple comparison
      (Agg, Group, Unique, SetOp).  Formerly the executor looked up the default
      equality operator for the datatype, which was really pretty shaky, since it's
      possible that the data being fed to the node is sorted according to some
      nondefault operator class that could have an incompatible idea of equality.
      The planner knows what it has sorted by and therefore can provide the right
      equality operator to use.  Also, this change moves a couple of catalog lookups
      out of the executor and into the planner, which should help startup time for
      pre-planned queries by some small amount.  Modify the planner to remove some
      other cavalier assumptions about always being able to use the default
      operators.  Also add "nulls first/last" info to the Plan node for a mergejoin
      --- neither the executor nor the planner can cope yet, but at least the API is
      in place.
      a191a169
  12. 09 1月, 2007 1 次提交
    • T
      Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST · 44317582
      Tom Lane 提交于
      per-column options for btree indexes.  The planner's support for this is still
      pretty rudimentary; it does not yet know how to plan mergejoins with
      nondefault ordering options.  The documentation is pretty rudimentary, too.
      I'll work on improving that stuff later.
      
      Note incompatible change from prior behavior: ORDER BY ... USING will now be
      rejected if the operator is not a less-than or greater-than member of some
      btree opclass.  This prevents less-than-sane behavior if an operator that
      doesn't actually define a proper sort ordering is selected.
      44317582
  13. 06 1月, 2007 1 次提交
  14. 24 12月, 2006 1 次提交
  15. 28 11月, 2006 1 次提交
  16. 04 10月, 2006 1 次提交
  17. 15 8月, 2006 1 次提交
    • T
      Cause '*' and 'foo.*' notations to mark the referenced RTE(s) as · 58538a0f
      Tom Lane 提交于
      requiring read permissions.  Up till now there was no possible case
      in which the RTEs wouldn't already have ACL_SELECT set ... but now that
      you can say something like 'INSERT INTO foo ... RETURNING *' this is
      an essential step.  With this commit, a RETURNING clause adds the
      requirement for SELECT permissions on the target table if and only if
      the clause actually reads the value of at least one target-table column.
      58538a0f
  18. 13 8月, 2006 1 次提交
    • T
      Tweak SPI_cursor_open to allow INSERT/UPDATE/DELETE RETURNING; this was · 3f8db37c
      Tom Lane 提交于
      merely a matter of fixing the error check, since the underlying Portal
      infrastructure already handles it.  This in turn allows these statements
      to be used in some existing plpgsql and plperl contexts, such as a
      plpgsql FOR loop.  Also, do some marginal code cleanup in places that
      were being sloppy about distinguishing SELECT from SELECT INTO.
      3f8db37c
  19. 27 7月, 2006 1 次提交
  20. 26 7月, 2006 1 次提交
  21. 14 7月, 2006 2 次提交
  22. 04 7月, 2006 1 次提交
    • T
      Code review for FILLFACTOR patch. Change WITH grammar as per earlier · b7b78d24
      Tom Lane 提交于
      discussion (including making def_arg allow reserved words), add missed
      opt_definition for UNIQUE case.  Put the reloptions support code in a less
      random place (I chose to make a new file access/common/reloptions.c).
      Eliminate header inclusion creep.  Make the index options functions safely
      user-callable (seems like client apps might like to be able to test validity
      of options before trying to make an index).  Reduce overhead for normal case
      with no options by allowing rd_options to be NULL.  Fix some unmaintainably
      klugy code, including getting rid of Natts_pg_class_fixed at long last.
      Some stylistic cleanup too, and pay attention to keeping comments in sync
      with code.
      
      Documentation still needs work, though I did fix the omissions in
      catalogs.sgml and indexam.sgml.
      b7b78d24
  23. 02 7月, 2006 1 次提交
  24. 16 3月, 2006 1 次提交
    • T
      Clean up representation of function RTEs for functions returning RECORD. · 23160139
      Tom Lane 提交于
      The original coding stored the raw parser output (ColumnDef and TypeName
      nodes) which was ugly, bulky, and wrong because it failed to create any
      dependency on the referenced datatype --- and in fact would not track type
      renamings and suchlike.  Instead store a list of column type OIDs in the
      RTE.
      
      Also fix up general failure of recordDependencyOnExpr to do anything sane
      about recording dependencies on datatypes.  While there are many cases where
      there will be an indirect dependency (eg if an operator returns a datatype,
      the dependency on the operator is enough), we do have to record the datatype
      as a separate dependency in examples like CoerceToDomain.
      
      initdb forced because of change of stored rules.
      23160139
  25. 15 3月, 2006 1 次提交
    • T
      Improve parser so that we can show an error cursor position for errors · 20ab467d
      Tom Lane 提交于
      during parse analysis, not only errors detected in the flex/bison stages.
      This is per my earlier proposal.  This commit includes all the basic
      infrastructure, but locations are only tracked and reported for errors
      involving column references, function calls, and operators.  More could
      be done later but this seems like a good set to start with.  I've also
      moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
      which should make it available to more people --- even within psql this
      is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
      20ab467d
  26. 06 3月, 2006 1 次提交
    • N
      Per recent discussion on -hackers, we should sometimes reorder the · 99114a24
      Neil Conway 提交于
      columns of the grouping clause to avoid redundant sorts. The optimizer
      is not currently capable of doing this, so this patch implements a
      simple hack in the analysis phase (transformGroupClause): if any
      subset of the GROUP BY clause matches a prefix of the ORDER BY list,
      that prefix is moved to the front of the GROUP BY clause. This
      shouldn't change the semantics of the query, and allows a redundant
      sort to be avoided for queries like "GROUP BY a, b ORDER BY b".
      99114a24
  27. 05 3月, 2006 1 次提交
  28. 22 1月, 2006 1 次提交
    • N
      Allow an optional alias for the target table to be specified for UPDATE · 1d763d91
      Neil Conway 提交于
      and DELETE. If specified, the alias must be used instead of the full
      table name. Also, the alias currently cannot be used in the SET clause
      of UPDATE.
      
      Patch from Atsushi Ogawa, various editorialization by Neil Conway.
      Along the way, make the rowtypes regression test pass if add_missing_from
      is enabled, and add a new (skeletal) regression test for DELETE.
      1d763d91
  29. 23 11月, 2005 1 次提交
  30. 15 10月, 2005 1 次提交
  31. 05 6月, 2005 2 次提交
    • T
      Replace the parser's namespace tree (which formerly had the same · a4996a89
      Tom Lane 提交于
      representation as the jointree) with two lists of RTEs, one showing
      the RTEs accessible by qualified names, and the other showing the RTEs
      accessible by unqualified names.  I think this is conceptually simpler
      than what we did before, and it's sure a whole lot easier to search.
      This seems to eliminate the parse-time bottleneck for deeply nested
      JOIN structures that was exhibited by phil@vodafone.
      a4996a89
    • T
      Change expandRTE() and ResolveNew() back to taking just the single · e18e8f87
      Tom Lane 提交于
      RTE of interest, rather than the whole rangetable list.  This makes
      the API more understandable and avoids duplicate RTE lookups.  This
      patch reverts no-longer-needed portions of my patch of 2004-08-19.
      e18e8f87
  32. 14 4月, 2005 1 次提交
    • T
      Change addRangeTableEntryForRelation() to take a Relation pointer instead · 2fdf9e0b
      Tom Lane 提交于
      of just a relation OID, thereby not having to open the relation for itself.
      This actually saves code rather than adding it for most of the existing
      callers, which had the rel open already.  The main point though is to be
      able to use this rather than plain addRangeTableEntry in setTargetTable,
      thus saving one relation_openrv/relation_close cycle for every INSERT,
      UPDATE, or DELETE.  Seems to provide a several percent win on simple
      INSERTs.
      2fdf9e0b
  33. 07 4月, 2005 1 次提交
    • T
      Merge Resdom nodes into TargetEntry nodes to simplify code and save a · ad161bcc
      Tom Lane 提交于
      few palloc's.  I also chose to eliminate the restype and restypmod fields
      entirely, since they are redundant with information stored in the node's
      contained expression; re-examining the expression at need seems simpler
      and more reliable than trying to keep restype/restypmod up to date.
      
      initdb forced due to change in contents of stored rules.
      ad161bcc
  34. 01 1月, 2005 1 次提交
    • P
      · 2ff50159
      PostgreSQL Daemon 提交于
      Tag appropriate files for rc3
      
      Also performed an initial run through of upgrading our Copyright date to
      extend to 2005 ... first run here was very simple ... change everything
      where: grep 1996-2004 && the word 'Copyright' ... scanned through the
      generated list with 'less' first, and after, to make sure that I only
      picked up the right entries ...
      2ff50159
  35. 30 9月, 2004 1 次提交
  36. 29 8月, 2004 2 次提交
  37. 20 8月, 2004 1 次提交
    • T
      Repair some issues with column aliases and RowExpr construction in the · bbd6eb5b
      Tom Lane 提交于
      presence of dropped columns.  Document the already-presumed fact that
      eref aliases in relation RTEs are supposed to have entries for dropped
      columns; cause the user alias structs to have such entries too, so that
      there's always a one-to-one mapping to the underlying physical attnums.
      Adjust expandRTE() and related code to handle the case where a column
      that is part of a JOIN has been dropped.  Generalize expandRTE()'s API
      so that it can be used in a couple of places that formerly rolled their
      own implementation of the same logic.  Fix ruleutils.c to suppress
      display of aliases for columns that were dropped since the rule was made.
      bbd6eb5b