Skip to content
Snippets Groups Projects
  1. Dec 29, 2009
    • Heikki Linnakangas's avatar
      Previous fix for temporary file management broke returning a set from · 84d723b6
      Heikki Linnakangas authored
      PL/pgSQL function within an exception handler. Make sure we use the right
      resource owner when we create the tuplestore to hold returned tuples.
      
      Simplify tuplestore API so that the caller doesn't need to be in the right
      memory context when calling tuplestore_put* functions. tuplestore.c
      automatically switches to the memory context used when the tuplestore was
      created. Tuplesort was already modified like this earlier. This patch also
      removes the now useless MemoryContextSwitch calls from callers.
      
      Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
      the previous patch that broke this.
      84d723b6
  2. Dec 25, 2009
  3. Dec 19, 2009
  4. Dec 15, 2009
    • Peter Eisentraut's avatar
      Python 3 support in PL/Python · dd4cd55c
      Peter Eisentraut authored
      Behaves more or less unchanged compared to Python 2, but the new language
      variant is called plpython3u.  Documentation describing the naming scheme
      is included.
      dd4cd55c
  5. Dec 10, 2009
  6. Dec 07, 2009
  7. Nov 29, 2009
  8. Nov 13, 2009
    • Tom Lane's avatar
      Add control knobs for plpgsql's variable resolution behavior, and make the · 63176099
      Tom Lane authored
      default be "throw error on conflict", as per discussions.  The GUC variable
      is plpgsql.variable_conflict, with values "error", "use_variable",
      "use_column".  The behavior can also be specified per-function by inserting
      one of
      	#variable_conflict error
      	#variable_conflict use_variable
      	#variable_conflict use_column
      at the start of the function body.
      
      The 8.5 release notes will need to mention using "use_variable" to retain
      backward-compatible behavior, although we should encourage people to migrate
      to the much less mistake-prone "error" setting.
      
      Update the plpgsql documentation to match this and other recent changes.
      63176099
  9. Nov 12, 2009
    • Tom Lane's avatar
      Remove plpgsql's separate lexer (finally!), in favor of using the core lexer · 2dee828c
      Tom Lane authored
      directly.  This was a lot of trouble, but should be worth it in terms of
      not having to keep the plpgsql lexer in step with core anymore.  In addition
      the handling of keywords is significantly better-structured, allowing us to
      de-reserve a number of words that plpgsql formerly treated as reserved.
      2dee828c
  10. Nov 10, 2009
    • Tom Lane's avatar
      More incremental refactoring in plpgsql: get rid of gram.y dependencies on · 73a2f6c6
      Tom Lane authored
      yytext.  This is a necessary change if we're going to have a lexer interface
      layer that does lookahead, since yytext won't necessarily be in step with
      what the grammar thinks is the current token.  yylval and yylloc should
      be the only side-variables that we need to manage when doing lookahead.
      73a2f6c6
  11. Nov 09, 2009
    • Tom Lane's avatar
      Modernize plpgsql's handling of parse locations, making it look a lot more · 39bd3fd1
      Tom Lane authored
      like the core parser's code.  In particular, track locations at the character
      rather than line level during parsing, allowing many more parse-time error
      conditions to be reported with precise error pointers rather than just
      "near line N".
      
      Also, exploit the fact that we no longer need to substitute $N for variable
      references by making extracted SQL queries and expressions be exact copies
      of subranges of the function text, rather than having random whitespace
      changes within them.  This makes it possible to directly map parse error
      positions from the core parser onto positions in the function text, which
      lets us report them without the previous kluge of showing the intermediate
      internal-query form.  (Later it might be good to do that for core
      parse-analysis errors too, but this patch is just touching plpgsql's
      lexer/parser, not what happens at runtime.)
      
      In passing, make plpgsql's lexer use palloc not malloc.
      
      These changes make plpgsql's parse-time error reports noticeably nicer
      (as illustrated by the regression test changes), and will also simplify
      the planned removal of plpgsql's separate lexer by reducing the impedance
      mismatch between what it does and what the core lexer does.
      39bd3fd1
  12. Nov 07, 2009
    • Tom Lane's avatar
      Remove ancient text file containing plpgsql installation instructions. · fb60af41
      Tom Lane authored
      This was long ago superseded by the standard build process and main
      SGML documentation.
      fb60af41
    • Tom Lane's avatar
      Rearrange plpgsql parsing to simplify and speed it up a bit. · f2b7692e
      Tom Lane authored
      * Pull the responsibility for %TYPE and %ROWTYPE out of the scanner,
      letting read_datatype manage it instead.
      
      * Avoid unnecessary scanner-driven lookups of plpgsql variables in
      places where it's not needed, which is actually most of the time;
      we do not need it in DECLARE sections nor in text that is a SQL
      query or expression.
      
      * Rationalize the set of token types returned by the scanner:
      distinguishing T_SCALAR, T_RECORD, T_ROW seems to complicate the grammar
      in more places than it simplifies it, so merge these into one
      token type T_DATUM; but split T_ERROR into T_DBLWORD and T_TRIPWORD
      for clarity and simplicity of later processing.
      
      Some of this will need to be revisited again when we try to make
      plpgsql use the core scanner, but this patch gets some of the bigger
      stumbling blocks out of the way.
      f2b7692e
  13. Nov 06, 2009
    • Tom Lane's avatar
      Change plpgsql from using textual substitution to insert variable references · 0772f1e5
      Tom Lane authored
      into SQL expressions, to using the newly added parser callback hooks.
      
      This allows us to do the substitutions in a more semantically-aware way:
      a variable reference will only be recognized where it can validly go,
      ie, a place where a column value or parameter would be legal, instead of
      the former behavior that would replace any textual match including
      table names and column aliases (leading to syntax errors later on).
      A release-note-worthy fine point is that plpgsql variable names that match
      fully-reserved words will now need to be quoted.
      
      This commit preserves the former behavior that variable references take
      precedence over any possible match to a column name.  The infrastructure
      is in place to support the reverse precedence or throwing an error on
      ambiguity, but those behaviors aren't accessible yet.
      
      Most of the code changes here are associated with making the namespace
      data structure persist so that it can be consulted at runtime, instead
      of throwing it away at the end of initial function parsing.
      
      The plpgsql scanner is still doing name lookups, but that behavior is
      now irrelevant for SQL expressions.  A future commit will deal with
      removing unnecessary lookups.
      0772f1e5
  14. Nov 05, 2009
    • Tom Lane's avatar
      Remove plpgsql's RENAME declaration, which has bizarre and mostly nonfunctional · c29ae527
      Tom Lane authored
      behavior, and is so little used that no one has been interested in fixing it.
      To ensure that possible uses are covered, remove the ALIAS declaration's
      arbitrary restriction that only $n identifiers can be aliased.
      
      (We could alternatively make RENAME act just like ALIAS, but per discussion
      having two different ways to do the same thing is probably more confusing than
      helpful.)
      c29ae527
  15. Nov 04, 2009
    • Tom Lane's avatar
      Add support for invoking parser callback hooks via SPI and in cached plans. · 9bedd128
      Tom Lane authored
      As proof of concept, modify plpgsql to use the hooks.  plpgsql is still
      inserting $n symbols textually, but the "back end" of the parsing process now
      goes through the ParamRef hook instead of using a fixed parameter-type array,
      and then execution only fetches actually-referenced parameters, using a hook
      added to ParamListInfo.
      
      Although there's a lot left to be done in plpgsql, this already cures the
      "if (TG_OP = 'INSERT' and NEW.foo ...)"  problem, as illustrated by the
      changed regression test.
      9bedd128
  16. Nov 03, 2009
    • Peter Eisentraut's avatar
      Improve PL/Python elog output · 2e3b16c8
      Peter Eisentraut authored
      When the elog functions (plpy.info etc.) get a single argument, just print
      that argument instead of printing the single-member tuple like ('foo',).
      2e3b16c8
    • Peter Eisentraut's avatar
      Fix obscure segfault condition in PL/Python · 9e411146
      Peter Eisentraut authored
      In PLy_output(), when the elog() call in the TRY branch throws an exception
      (this can happen when a statement timeout kicks in, for example), the
      PyErr_SetString() call in the CATCH branch can cause a segfault, because the
      Py_XDECREF(so) call before it releases memory that is still used by the sv
      variable that PyErr_SetString() uses as argument, because sv points into
      memory owned by so.
      
      Backpatched back to 8.0, where this code was introduced.
      
      I also threw in a couple of volatile declarations for variables that are used
      before and after the TRY.  I don't think they caused the crash that I
      observed, but they could become issues.
      9e411146
  17. Oct 31, 2009
  18. Oct 20, 2009
  19. Oct 16, 2009
  20. Oct 14, 2009
  21. Sep 29, 2009
  22. Sep 28, 2009
  23. Sep 23, 2009
    • Tom Lane's avatar
      Implement the DO statement to support execution of PL code without having · 9048b731
      Tom Lane authored
      to create a function for it.
      
      Procedural languages now have an additional entry point, namely a function
      to execute an inline code block.  This seemed a better design than trying
      to hide the transient-ness of the code from the PL.  As of this patch, only
      plpgsql has an inline handler, but probably people will soon write handlers
      for the other standard PLs.
      
      In passing, remove the long-dead LANCOMPILER option of CREATE LANGUAGE.
      
      Petr Jelinek
      9048b731
  24. Sep 20, 2009
    • Tom Lane's avatar
      Allow plpgsql IN parameters to be assigned to. Since the parameters are just · 0f427dfe
      Tom Lane authored
      preinitialized local variables, this does not affect the function's semantics
      as seen by callers; allowing assignment simply avoids the need to create more
      local variables in some cases.  In any case we were being rather inconsistent
      since only scalar parameters were getting marked constant.
      
      No documentation change, since parameters were never documented as being
      marked constant anyway.
      
      Steve Prentice
      0f427dfe
  25. Sep 16, 2009
  26. Sep 14, 2009
    • Peter Eisentraut's avatar
      Fix Unicode support in PL/Python · eb62398f
      Peter Eisentraut authored
      Check calls of PyUnicode_AsEncodedString() for NULL return, probably
      because the encoding name is not known.  Add special treatment for
      SQL_ASCII, which Python definitely does not know.
      
      Since using SQL_ASCII produces errors in the regression tests when
      non-ASCII characters are involved, we have to put back various regression
      test result variants.
      eb62398f
  27. Sep 13, 2009
    • Peter Eisentraut's avatar
      Add Unicode support in PL/Python · 4ab6ebf3
      Peter Eisentraut authored
      PL/Python now accepts Unicode objects where it previously only accepted string
      objects (for example, as return value).  Unicode objects are converted to the
      PostgreSQL server encoding as necessary.
      
      This change is also necessary for future Python 3 support, which treats all
      strings as Unicode objects.
      
      Since this removes the error conditions that the plpython_unicode test file
      tested for, the alternative result files are no longer necessary.
      4ab6ebf3
  28. Sep 12, 2009
  29. Sep 09, 2009
    • Peter Eisentraut's avatar
      Fix/improve bytea and boolean support in PL/Python · 3ab8b7fa
      Peter Eisentraut authored
      Before, PL/Python converted data between SQL and Python by going
      through a C string representation.  This broke for bytea in two ways:
      
      - On input (function parameters), you would get a Python string that
        contains bytea's particular external representation with backslashes
        etc., instead of a sequence of bytes, which is what you would expect
        in a Python environment.  This problem is exacerbated by the new
        bytea output format.
      
      - On output (function return value), null bytes in the Python string
        would cause truncation before the data gets stored into a bytea
        datum.
      
      This is now fixed by converting directly between the PostgreSQL datum
      and the Python representation.
      
      The required generalized infrastructure also allows for other
      improvements in passing:
      
      - When returning a boolean value, the SQL datum is now true if and
        only if Python considers the value that was passed out of the
        PL/Python function to be true.  Previously, this determination was
        left to the boolean data type input function.  So, now returning
        'foo' results in true, because Python considers it true, rather than
        false because PostgreSQL considers it false.
      
      - On input, we can convert the integer and float types directly to
        their Python equivalents without having to go through an
        intermediate string representation.
      
      original patch by Caleb Welton, with updates by myself
      3ab8b7fa
  30. Aug 28, 2009
  31. Aug 27, 2009
    • Peter Eisentraut's avatar
      Update of install-sh, mkinstalldirs, and associated configury · 9d182ef0
      Peter Eisentraut authored
      Update install-sh to that from Autoconf 2.63, plus our Darwin-specific
      changes (which I simplified a bit).  install-sh is now able to install
      multiple files in one run, so we could simplify our makefiles sometime.
      
      install-sh also now has a -d option to create directories, so we don't need
      mkinstalldirs anymore.
      
      Use AC_PROG_MKDIR_P in configure.in, so we can use mkdir -p when available
      instead of install-sh -d.  For consistency with the rest of the world,
      the corresponding make variable has been renamed from $(mkinstalldirs) to
      $(MKDIR_P).
      9d182ef0
  32. Aug 25, 2009
  33. Aug 24, 2009
  34. Aug 15, 2009
  35. Aug 14, 2009
Loading