1. 22 Feb, 2005 1 commit
    • Neil Conway's avatar
      This patch changes makes some significant changes to how compilation · 5a9dd0dc
      Neil Conway authored
      and parsing work in PL/PgSQL:
      
      - memory management is now done via palloc(). The compiled representation
        of each function now has its own memory context. Therefore, the storage
        consumed by a function can be reclaimed via MemoryContextDelete().
      
        During compilation, the CurrentMemoryContext is the function's memory
        context. This means that a palloc() is sufficient to allocate memory
        that will have the same lifetime as the function itself. As a result,
        code invoked during compilation should be careful to pfree() temporary
        allocations to avoid leaking memory. Since a lot of the code in the
        backend is not careful about releasing palloc'ed memory, that means
        we should switch into a temporary memory context before invoking
        backend functions. A temporary context appropriate for such allocations
        is `compile_tmp_cxt'.
      
      - The ability to use palloc() allows us to simply a lot of the code in
        the parser. Rather than representing lists of elements via ad hoc
        linked lists or arrays, we can use the List type. Rather than doing
        malloc followed by memset(0), we can just use palloc0().
      
      - We now check that the user has supplied the right number of parameters
        to a RAISE statement. Supplying either too few or too many results in
        an error (at runtime).
      
      - PL/PgSQL's parser needs to accept arbitrary SQL statements. Since we
        do not want to duplicate the SQL grammar in the PL/PgSQL grammar, this
        means we need to be quite lax in what the PL/PgSQL grammar considers
        a "SQL statement". This can lead to misleading behavior if there is a
        syntax error in the function definition, since we assume a malformed
        PL/PgSQL construct is a SQL statement. Furthermore, these errors were
        only detected at runtime (when we tried to execute the alleged "SQL
        statement" via SPI).
      
        To rectify this, the patch changes the parser to invoke the main SQL
        parser when it sees a string it believes to be a SQL expression. This
        means that synctically-invalid SQL will be rejected during the
        compilation of the PL/PgSQL function. This is only done when compiling
        for "validation" purposes (i.e. at CREATE FUNCTION time), so it should
        not impose a runtime overhead.
      
      - Fixes for the various buffer overruns I've patched in stable branches
        in the past few weeks. I've rewritten code where I thought it was
        warranted (unlike the patches applied to older branches, which were
        minimally invasive).
      
      - Various other minor changes and cleanups.
      
      - Updates to the regression tests.
      5a9dd0dc
  2. 19 Jan, 2005 1 commit
  3. 21 Dec, 2004 1 commit
  4. 19 Dec, 2004 1 commit
  5. 16 Nov, 2004 1 commit
    • Tom Lane's avatar
      Rethink plpgsql's way of handling SPI execution during an exception block. · 7efa8411
      Tom Lane authored
      We don't really want to start a new SPI connection, just keep using the old
      one; otherwise we have memory management problems as illustrated by
      John Kennedy's bug report of today.  This requires a bit of a hack to
      ensure the SPI stack state is properly restored, but then again what we
      were doing before was a hack too, strictly speaking.  Add a regression
      test to cover this case.
      7efa8411
  6. 20 Sep, 2004 1 commit
  7. 10 Sep, 2004 1 commit
    • Tom Lane's avatar
      Fire non-deferred AFTER triggers immediately upon query completion, · b339d1ff
      Tom Lane authored
      rather than when returning to the idle loop.  This makes no particular
      difference for interactively-issued queries, but it makes a big difference
      for queries issued within functions: trigger execution now occurs before
      the calling function is allowed to proceed.  This responds to numerous
      complaints about nonintuitive behavior of foreign key checking, such as
      http://archives.postgresql.org/pgsql-bugs/2004-09/msg00020.php, and
      appears to be required by the SQL99 spec.
      Also take the opportunity to simplify the data structures used for the
      pending-trigger list, rename them for more clarity, and squeeze out a
      bit of space.
      b339d1ff
  8. 31 Jul, 2004 2 commits
    • Tom Lane's avatar
      Support "OR condition ..." in plpgsql EXCEPTION clauses to make the syntax · 9c8d0850
      Tom Lane authored
      more nearly Oracle-equivalent.  Allow matching by category as well as
      specific error code.  Document the set of available condition names
      (or more accurately, synchronize it with the existing documentation).  In
      passing, update errcodes.sgml to include codes added during 7.5 development.
      9c8d0850
    • Tom Lane's avatar
      plpgsql does exceptions. · beda4814
      Tom Lane authored
      There are still some things that need refinement; in particular I fear
      that the recognized set of error condition names probably has little in
      common with what Oracle recognizes.  But it's a start.
      beda4814
  9. 21 Nov, 2003 1 commit
    • Tom Lane's avatar
      COMMENT ON casts, conversions, languages, operator classes, and · 42ce74bf
      Tom Lane authored
      large objects.  Dump all these in pg_dump; also add code to pg_dump
      user-defined conversions.  Make psql's large object code rely on
      the backend for inserting/deleting LOB comments, instead of trying to
      hack pg_description directly.  Documentation and regression tests added.
      
      Christopher Kings-Lynne, code reviewed by Tom
      42ce74bf
  10. 25 Sep, 2003 1 commit
  11. 27 Jul, 2003 1 commit
  12. 21 Jul, 2003 1 commit
  13. 24 Apr, 2003 1 commit
    • Tom Lane's avatar
      Infrastructure for upgraded error reporting mechanism. elog.c is · f690920a
      Tom Lane authored
      rewritten and the protocol is changed, but most elog calls are still
      elog calls.  Also, we need to contemplate mechanisms for controlling
      all this functionality --- eg, how much stuff should appear in the
      postmaster log?  And what API should libpq expose for it?
      f690920a
  14. 10 Nov, 2002 1 commit
    • Bruce Momjian's avatar
      This patch makes a minor cleanup to the implementation of PERFORM in · cfd27281
      Bruce Momjian authored
      PL/PgSQL. Previously, it had been bundled together with the assign
      statement implementation, for some reason that wasn't clear to me
      (they certainly don't share any code with one another). So I separated
      them and made PERFORM a statement like any other. No changes in
      functionality.
      
      Along the way, I added some regression tests for PERFORM, added a
      bunch more SGML tags to the PL/PgSQL docs, and removed an obsolete
      comment relating to the implementation of RETURN NEXT.
      
      Neil Conway
      cfd27281
  15. 01 Sep, 2002 1 commit
  16. 30 Aug, 2002 1 commit
  17. 22 Aug, 2002 2 commits
  18. 20 Aug, 2002 1 commit
    • Bruce Momjian's avatar
      This patch improves the behavior of FOUND in PL/PgSQL. In Oracle, · ebe1be13
      Bruce Momjian authored
      FOUND is set whenever a SELECT INTO returns > 0 rows, *or* when an
      INSERT, UPDATE, or DELETE affects > 0 rows. We implemented the first
      part of this behavior, but not the second.
      
      I also improved the documentation on the various situations in which
      FOUND can be set (excluding inside FOR loops, which I still need to
      think about), and added some regression tests for this behavior.
      
      Neil Conway
      ebe1be13
  19. 21 Sep, 2001 1 commit
    • Tom Lane's avatar
      Quick-and-dirty fix for recursive plpgsql functions, per bug report from · ae3129fd
      Tom Lane authored
      Frank Miles 7-Sep-01.  This is really just sticking a finger in the dike.
      Frank's case works now, but we still couldn't support a recursive function
      returning a set.  Really need to restructure querytrees and execution
      state so that the querytree is *read only*.  We've run into this over and
      over and over again ... it has to happen sometime soon.
      ae3129fd
  20. 22 Oct, 2000 1 commit
    • Tom Lane's avatar
      Some small polishing of Mark Hollomon's cleanup of DROP command: might · 9ace0318
      Tom Lane authored
      as well allow DROP multiple INDEX, RULE, TYPE as well.  Add missing
      CommandCounterIncrement to DROP loop, which could cause trouble otherwise
      with multiple DROP of items affecting same catalog entries.  Try to
      bring a little consistency to various error messages using 'does not exist',
      'nonexistent', etc --- I standardized on 'does not exist' since that's
      what the vast majority of the existing uses seem to be.
      9ace0318
  21. 09 Jan, 2000 2 commits
  22. 23 Nov, 1999 1 commit
  23. 01 Oct, 1998 1 commit
    • Marc G. Fournier's avatar
      · 2074b5f1
      Marc G. Fournier authored
      failed to add some of Jan's files :(
      2074b5f1
  24. 24 Aug, 1998 1 commit
  25. 22 Aug, 1998 1 commit
    • Bruce Momjian's avatar
      As proposed, here is the current version of PL/pgSQL. The · 863a6206
      Bruce Momjian authored
          test isn't that complete up to now,  but  I  think  it  shows
          enough of the capabilities of the module.
      
          The  Makefile  assumes  it  is  located  in a directory under
          pgsql/src/pl.   Since   it   includes   Makefile.global   and
          Makefile.port  and doesn't use any own compiler/linker calls,
          it should build on most of our supported  platforms  (I  only
          tested  under Linux up to now).  It requires flex and bison I
          think. Maybe we should ship prepared gram.c etc. like for the
          main parser too?
      
      
      Jan
      863a6206