1. 20 Oct, 2008 1 commit
  2. 04 Oct, 2008 1 commit
    • 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
  3. 23 Sep, 2008 1 commit
  4. 11 Sep, 2008 1 commit
    • Tom Lane's avatar
      Adjust the parser to accept the typename syntax INTERVAL ... SECOND(n) · 70530c80
      Tom Lane authored
      and the literal syntax INTERVAL 'string' ... SECOND(n), as required by the
      SQL standard.  Our old syntax put (n) directly after INTERVAL, which was
      a mistake, but will still be accepted for backward compatibility as well
      as symmetry with the TIMESTAMP cases.
      
      Change intervaltypmodout to show it in the spec's way, too.  (This could
      potentially affect clients, if there are any that analyze the typmod of an
      INTERVAL in any detail.)
      
      Also fix interval input to handle 'min:sec.frac' properly; I had overlooked
      this case in my previous patch.
      
      Document the use of the interval fields qualifier, which up to now we had
      never mentioned in the docs.  (I think the omission was intentional because
      it didn't work per spec; but it does now, or at least close enough to be
      credible.)
      70530c80
  5. 02 Sep, 2008 1 commit
  6. 01 Sep, 2008 1 commit
  7. 30 Aug, 2008 1 commit
  8. 28 Aug, 2008 1 commit
    • 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
  9. 18 Jul, 2008 1 commit
  10. 16 Jul, 2008 1 commit
    • Tom Lane's avatar
      Support "variadic" functions, which can accept a variable number of arguments · d89737d3
      Tom Lane authored
      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
  11. 15 Jun, 2008 1 commit
    • Tom Lane's avatar
      Rearrange ALTER TABLE syntax processing as per my recent proposal: the · a0b012a1
      Tom Lane authored
      grammar allows ALTER TABLE/INDEX/SEQUENCE/VIEW interchangeably for all
      subforms of those commands, and then we sort out what's really legal
      at execution time.  This allows the ALTER SEQUENCE/VIEW reference pages
      to fully document all the ALTER forms available for sequences and views
      respectively, and eliminates a longstanding cause of confusion for users.
      
      The net effect is that the following forms are allowed that weren't before:
      	ALTER SEQUENCE OWNER TO
      	ALTER VIEW ALTER COLUMN SET/DROP DEFAULT
      	ALTER VIEW OWNER TO
      	ALTER VIEW SET SCHEMA
      (There's no actual functionality gain here, but formerly you had to say
      ALTER TABLE instead.)
      
      Interestingly, the grammar tables actually get smaller, probably because
      there are fewer special cases to keep track of.
      
      I did not disallow using ALTER TABLE for these operations.  Perhaps we
      should, but there's a backwards-compatibility issue if we do; in fact
      it would break existing pg_dump scripts.  I did however tighten up
      ALTER SEQUENCE and ALTER VIEW to reject non-sequences and non-views
      in the new cases as well as a couple of cases where they didn't before.
      
      The patch doesn't change pg_dump to use the new syntaxes, either.
      a0b012a1
  12. 16 May, 2008 1 commit
    • Tom Lane's avatar
      Add a RESTART (without parameter) option to ALTER SEQUENCE, allowing a · 10a3471b
      Tom Lane authored
      sequence to be reset to its original starting value.  This requires adding the
      original start value to the set of parameters (columns) of a sequence object,
      which is a user-visible change with potential compatibility implications;
      it also forces initdb.
      
      Also add hopefully-SQL-compatible RESTART/CONTINUE IDENTITY options to
      TRUNCATE TABLE.  RESTART IDENTITY executes ALTER SEQUENCE RESTART for all
      sequences "owned by" any of the truncated relations.  CONTINUE IDENTITY is
      a no-op option.
      
      Zoltan Boszormenyi
      10a3471b
  13. 29 Apr, 2008 2 commits
  14. 14 Apr, 2008 1 commit
    • Tom Lane's avatar
      Push index operator lossiness determination down to GIST/GIN opclass · 9b5c8d45
      Tom Lane authored
      "consistent" functions, and remove pg_amop.opreqcheck, as per recent
      discussion.  The main immediate benefit of this is that we no longer need
      8.3's ugly hack of requiring @@@ rather than @@ to test weight-using tsquery
      searches on GIN indexes.  In future it should be possible to optimize some
      other queries better than is done now, by detecting at runtime whether the
      index match is exact or not.
      
      Tom Lane, after an idea of Heikki's, and with some help from Teodor.
      9b5c8d45
  15. 28 Mar, 2008 1 commit
  16. 21 Mar, 2008 1 commit
  17. 20 Mar, 2008 1 commit
    • Tom Lane's avatar
      Arrange for an explicit cast applied to an ARRAY[] constructor to be applied · 6b0706ac
      Tom Lane authored
      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
  18. 19 Mar, 2008 1 commit
  19. 15 Feb, 2008 1 commit
  20. 07 Feb, 2008 1 commit
    • Tom Lane's avatar
      Some variants of ALTER OWNER tried to make the "object" field of the · 1ab19a36
      Tom Lane authored
      statement be a list of bare C strings, rather than String nodes, which is
      what they need to be for copyfuncs/equalfuncs to work.  Fortunately these
      node types never go out to disk (if they did, we'd likely have noticed the
      problem sooner), so we can just fix it without creating a need for initdb.
      This bug has been there since 8.0, but 8.3 exposes it in a more common
      code path (Parse messages) than prior releases did.  Per bug #3940 from
      Vladimir Kokovic.
      1ab19a36
  21. 01 Jan, 2008 1 commit
  22. 29 Oct, 2007 1 commit
    • Tom Lane's avatar
      Remove the hack in the grammar that "optimized away" DEFAULT NULL clauses. · b17b7fae
      Tom Lane authored
      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
  23. 24 Sep, 2007 1 commit
  24. 03 Sep, 2007 2 commits
  25. 22 Aug, 2007 1 commit
  26. 21 Aug, 2007 2 commits
  27. 03 Jul, 2007 1 commit
  28. 23 Jun, 2007 1 commit
    • Tom Lane's avatar
      Separate parse-analysis for utility commands out of parser/analyze.c · 46379d6e
      Tom Lane authored
      (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
  29. 18 Jun, 2007 1 commit
    • Tom Lane's avatar
      Arrange for quote_identifier() and pg_dump to not quote keywords that are · 4c310eca
      Tom Lane authored
      unreserved according to the grammar.  The list of unreserved words has gotten
      extensive enough that the unnecessary quoting is becoming a bit of an eyesore.
      To do this, add knowledge of the keyword category to keywords.c's table.
      (Someday we might be able to generate keywords.c's table and the keyword lists
      in gram.y from a common source.)  For the moment, lie about WITH's status in
      the table so it will still get quoted --- this is because of the expectation
      that WITH will become reserved when the SQL recursive-queries patch gets done.
      
      I didn't force initdb because this affects nothing on-disk; but note that a
      few regression tests have changed expected output.
      4c310eca
  30. 15 Jun, 2007 1 commit
    • Tom Lane's avatar
      Tweak the API for per-datatype typmodin functions so that they are passed · 23347231
      Tom Lane authored
      an array of strings rather than an array of integers, and allow any simple
      constant or identifier to be used in typmods; for example
      	create table foo (f1 widget(42,'23skidoo',point));
      Of course the typmodin function has still got to pack this info into a
      non-negative int32 for storage, but it's still a useful improvement in
      flexibility, especially considering that you can do nearly anything if you
      are willing to keep the info in a side table.  We can get away with this
      change since we have not yet released a version providing user-definable
      typmods.  Per discussion.
      23347231
  31. 11 Jun, 2007 2 commits
    • Tom Lane's avatar
      Improve UPDATE/DELETE WHERE CURRENT OF so that they can be used from plpgsql · a9545b3a
      Tom Lane authored
      with a plpgsql-defined cursor.  The underlying mechanism for this is that the
      main SQL engine will now take "WHERE CURRENT OF $n" where $n is a refcursor
      parameter.  Not sure if we should document that fact or consider it an
      implementation detail.  Per discussion with Pavel Stehule.
      a9545b3a
    • 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
  32. 27 Apr, 2007 1 commit
    • Tom Lane's avatar
      Modify processing of DECLARE CURSOR and EXPLAIN so that they can resolve the · bbbe825f
      Tom Lane authored
      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
  33. 26 Apr, 2007 1 commit
    • Neil Conway's avatar
      Rename the newly-added commands for discarding session state. · 16efdb5e
      Neil Conway authored
      RESET SESSION, RESET PLANS, and RESET TEMP are now DISCARD ALL,
      DISCARD PLANS, and DISCARD TEMP, respectively. This is to avoid
      confusion with the pre-existing RESET variants: the DISCARD
      commands are not actually similar to RESET. Patch from Marko
      Kreen, with some minor editorialization.
      16efdb5e
  34. 16 Apr, 2007 1 commit
    • Tom Lane's avatar
      Expose more cursor-related functionality in SPI: specifically, allow · 66888f74
      Tom Lane authored
      access to the planner's cursor-related planning options, and provide new
      FETCH/MOVE routines that allow access to the full power of those commands.
      Small refactoring of planner(), pg_plan_query(), and pg_plan_queries()
      APIs to make it convenient to pass the planning options down from SPI.
      
      This is the core-code portion of Pavel Stehule's patch for scrollable
      cursor support in plpgsql; I'll review and apply the plpgsql changes
      separately.
      66888f74
  35. 12 Apr, 2007 1 commit
    • Neil Conway's avatar
      RESET SESSION, plus related new DDL commands. Patch from Marko Kreen, · d13e903b
      Neil Conway authored
      reviewed by Neil Conway. This patch adds the following DDL command
      variants: RESET SESSION, RESET TEMP, RESET PLANS, CLOSE ALL, and
      DEALLOCATE ALL. RESET SESSION is intended for use by connection
      pool software and the like, in order to reset a client session
      to something close to its initial state.
      
      Note that while most of these command variants can be executed
      inside a transaction block (but are not transaction-aware!),
      RESET SESSION cannot. While this is inconsistent, it is intended
      to catch programmer mistakes: RESET SESSION in an open transaction
      block is probably unintended.
      d13e903b
  36. 08 Apr, 2007 1 commit