summaryrefslogtreecommitdiff
path: root/src/pl/plpython
AgeCommit message (Collapse)Author
2013-03-05Remove dependency on the DLL of pythonxx.def file.Andrew Dunstan
This confused Cygwin's make because of the colon in the path. The DLL isn't likely to change under us so preserving the dependency doesn't gain us much, and it's useful to be able to do a native Windows build with the Cygwin mingw toolset. Noah Misch.
2013-02-03PL/Python: Add result object str handlerPeter Eisentraut
This is intended so that say plpy.debug(rv) prints something useful for debugging query execution results. reviewed by Steve Singer
2013-01-30Don't use spi_priv.h in plpython.Tom Lane
There may once have been a reason to violate modularity like that, but it doesn't appear that there is anymore.
2013-01-28Handle SPIErrors raised directly in PL/Python code.Heikki Linnakangas
If a PL/Python function raises an SPIError (or one if its subclasses) directly with python's raise statement, treat it the same as an SPIError generated internally. In particular, if the user sets the sqlstate attribute, preserve that. Oskari Saarenmaa and Jan Urbański, reviewed by Karl O. Pinc.
2013-01-25Fix plpython's handling of functions used as triggers on multiple tables.Tom Lane
plpython tried to use a single cache entry for a trigger function, but it needs a separate cache entry for each table the trigger is applied to, because there is table-dependent data in there. This was done correctly before 9.1, but commit 46211da1b84bc3537e799ee1126098e71c2428e8 broke it by simplifying the lookup key from "function OID and triggered table OID" to "function OID and is-trigger boolean". Go back to using both OIDs as the lookup key. Per bug report from Sandro Santilli. Andres Freund
2013-01-07Fix typoPeter Eisentraut
2013-01-05PL/Python: Make build on OS X more flexiblePeter Eisentraut
The PL/Python build on OS X was previously hardcoded to use the system installation of Python, ignoring whatever was specified to configure. Except that it would use the header files from configure, which could lead to mismatches. It was not possible to build against a custom Python installation. Now, we check in configure how the specified Python installation was built and use that, supporting framework and non-framework builds.
2013-01-05Revert "PL/Python: Remove workaround for returning booleans in Python <2.3"Peter Eisentraut
This reverts commit be0dfbad3671ed2503a2a661e70b48c5b364e069. The previous information that Py_RETURN_TRUE and Py_RETURN_FALSE are supported in Python 2.3 is wrong. They require Python 2.4. Update the comment about that.
2013-01-01Update copyrights for 2013Bruce Momjian
Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
2012-12-18Remove allow_nonpic_in_shlibPeter Eisentraut
This was used in a time when a shared libperl or libpython was difficult to come by. That is obsolete, and the idea behind the flag was never fully portable anyway and will likely fail on more modern CPU architectures.
2012-09-29PL/Python: Remove workaround for returning booleans in Python <2.3Peter Eisentraut
Since Python 2.2 is no longer supported, we can now use Py_RETURN_TRUE and Py_RETURN_FALSE instead of the old workaround.
2012-09-29PL/Python: Convert oid to long/intPeter Eisentraut
oid is a numeric type, so transform it to the appropriate Python numeric type like the other ones.
2012-09-16PL/Python: Improve Python 3 regression test setupPeter Eisentraut
Currently, we are making mangled copies of plpython/{expected,sql} to plpython/python3/{expected,sql}, and run the tests in plpython/python3. This has the disadvantage that the regression.diffs file, if any, ends up in plpython/python3, which is not the normal location. If we instead make the mangled copies in plpython/{expected,sql}/python3/, we can run the tests from the normal directory, regression.diffs ends up the normal place, and the pg_regress invocation also becomes a lot simpler. It's also more obvious at run time what's going on, because the tests end up being named "python3/something" in the test output.
2012-09-08Adjust PL/Python regression tests some more for Python 3.3.Tom Lane
Commit 2cfb1c6f77734db81b6e74bcae630f93b94f69be fixed some issues caused by Python 3.3 choosing to iterate through dict entries in a different order than before. But here's another one: the test cases adjusted here made two bad entries in a dict and expected the one complained of would always be the same. Possibly this should be back-patched further than 9.2, but there seems little point unless the earlier fix is too.
2012-08-30Split tuple struct defs from htup.h to htup_details.hAlvaro Herrera
This reduces unnecessary exposure of other headers through htup.h, which is very widely included by many files. I have chosen to move the function prototypes to the new file as well, because that means htup.h no longer needs to include tupdesc.h. In itself this doesn't have much effect in indirect inclusion of tupdesc.h throughout the tree, because it's also required by execnodes.h; but it's something to explore in the future, and it seemed best to do the htup.h change now while I'm busy with it.
2012-08-28add #includes to plpy_subxactobject.h to make it compile standaloneAlvaro Herrera
2012-08-06Perform conversion from Python unicode to string/bytes object via UTF-8.Heikki Linnakangas
We used to convert the unicode object directly to a string in the server encoding by calling Python's PyUnicode_AsEncodedString function. In other words, we used Python's routines to do the encoding. However, that has a few problems. First of all, it required keeping a mapping table of Python encoding names and PostgreSQL encodings. But the real killer was that Python doesn't support EUC_TW and MULE_INTERNAL encodings at all. Instead, convert the Python unicode object to UTF-8, and use PostgreSQL's encoding conversion functions to convert from UTF-8 to server encoding. We were already doing the same in the other direction in PLyUnicode_FromString, so this is more consistent, too. Note: This makes SQL_ASCII to behave more leniently. We used to map SQL_ASCII to Python's 'ascii', which on Python means strict 7-bit ASCII only, so you got an error if the python string contained anything but pure ASCII. You no longer get an error; you get the UTF-8 representation of the string instead. Backpatch to 9.0, where these conversions were introduced. Jan Urbański
2012-07-17PL/Python: Remove PLy_result_ass_itemPeter Eisentraut
It is apparently no longer used after the new slicing support was implemented (a97207b6908f1d4a7d19b37b818367bb0171039f), so let's remove the dead code and see if anything cares.
2012-07-05Revert part of the previous patch that avoided using PLy_elog().Heikki Linnakangas
That caused the plpython_unicode regression test to fail on SQL_ASCII encoding, as evidenced by the buildfarm. The reason is that with the patch, you don't get the detail in the error message that you got before. That detail is actually very informative, so rather than just adjust the expected output, let's revert that part of the patch for now to make the buildfarm green again, and figure out some other way to avoid the recursion of PLy_elog() that doesn't lose the detail.
2012-07-05Fix mapping of PostgreSQL encodings to Python encodings.Heikki Linnakangas
Windows encodings, "win1252" and so forth, are named differently in Python, like "cp1252". Also, if the PyUnicode_AsEncodedString() function call fails for some reason, use a plain ereport(), not a PLy_elog(), to report that error. That avoids recursion and crash, if PLy_elog() tries to call PLyUnicode_Bytes() again. This fixes bug reported by Asif Naeem. Backpatch down to 9.0, before that plpython didn't even try these conversions. Jan Urbański, with minor comment improvements by me.
2012-07-04Run newly-configured perltidy script on Perl files.Bruce Momjian
Run on HEAD and 9.2.
2012-07-04Reduce messages about implicit indexes and sequences to DEBUG1.Robert Haas
Per recent discussion on pgsql-hackers, these messages are too chatty for most users.
2012-06-10Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian
commit-fest.
2012-05-11PL/Python: Adjust the regression tests for Python 3.3Peter Eisentraut
The string representation of ImportError changed. Remove printing that; it's not necessary for the test. The order in which members of a dict are printed changed. But this was always implementation-dependent, so we have just been lucky for a long time. Do the printing the hard way to ensure sorted order.
2012-05-10PL/Python: Fix slicing support for result objects for Python 3Peter Eisentraut
The old way of implementing slicing support by implementing PySequenceMethods.sq_slice no longer works in Python 3. You now have to implement PyMappingMethods.mp_subscript. Do this by simply proxying the call to the wrapped list of result dictionaries. Consolidate some of the subscripting regression tests. Jan Urbański
2012-05-10PL/Python: Update incorrect commentPeter Eisentraut
Jan Urbański
2012-05-10Python 2.2 is no longer supportedPeter Eisentraut
It was already on its last legs, and it turns out that it was accidentally broken in commit 89e850e6fda9e4e441712012abe971fe938d595a and no one cared. So remove the rest the support for it and update the documentation to indicate that Python 2.3 is now required.
2012-05-02PL/Python: Improve test coveragePeter Eisentraut
Add test cases for inline handler of plython2u (when using that language name), and for result object element assignment. There is now at least one test case for every top-level functionality, except plpy.Fatal (annoying to use in regression tests) and result object slice retrieval and slice assignment (which are somewhat broken).
2012-05-02PL/Python: Fix crash in functions returning SETOF and using SPIPeter Eisentraut
Allocate PLyResultObject.tupdesc in TopMemoryContext, because its lifetime is the lifetime of the Python object and it shouldn't be freed by some other memory context, such as one controlled by SPI. We trust that the Python object will clean up its own memory. Before, this would crash the included regression test case by trying to use memory that was already freed. reported by Asif Naeem, analysis by Tom Lane
2012-05-02More duplicate word removal.Robert Haas
2012-04-26PL/Python: Accept strings in functions returning composite typesPeter Eisentraut
Before 9.1, PL/Python functions returning composite types could return a string and it would be parsed using record_in. The 9.1 changes made PL/Python only expect dictionaries, tuples, or objects supporting getattr as output of composite functions, resulting in a regression and a confusing error message, as the strings were interpreted as sequences and the code for transforming lists to database tuples was used. Fix this by treating strings separately as before, before checking for the other types. The reason why it's important to support string to database tuple conversion is that trigger functions on tables with composite columns get the composite row passed in as a string (from record_out). Without supporting converting this back using record_in, this makes it impossible to implement pass-through behavior for these columns, as PL/Python no longer accepts strings for composite values. A better solution would be to fix the code that transforms composite inputs into Python objects to produce dictionaries that would then be correctly interpreted by the Python->PostgreSQL counterpart code. But that would be too invasive to backpatch to 9.1, and it is too late in the 9.2 cycle to attempt it. It should be revisited in the future, though. Reported as bug #6559 by Kirill Simonov. Jan Urbański
2012-04-25PL/Python: Improve error messagesPeter Eisentraut
2012-04-16PL/Python: Improve documentation of nrows() methodPeter Eisentraut
Clarify that nrows() is the number of rows processed, versus the number of rows returned, which can be obtained using len. Also add tests about that.
2012-04-15PL/Python: Fix crash when colnames() etc. called without result setPeter Eisentraut
The result object methods colnames() etc. would crash when called after a command that did not produce a result set. Now they throw an exception. discovery and initial patch by Jean-Baptiste Quenot
2012-03-13Patch some corner-case bugs in pl/python.Tom Lane
Dave Malcolm of Red Hat is working on a static code analysis tool for Python-related C code. It reported a number of problems in plpython, most of which were failures to check for NULL results from object-creation functions, so would only be an issue in very-low-memory situations. Patch in HEAD and 9.1. We could go further back but it's not clear that these issues are important enough to justify the work. Jan Urbański
2012-03-13Fix minor memory leak in PLy_typeinfo_dealloc().Tom Lane
We forgot to free the per-attribute array element descriptors. Jan Urbański
2012-03-13Create a stack of pl/python "execution contexts".Tom Lane
This replaces the former global variable PLy_curr_procedure, and provides a place to stash per-call-level information. In particular we create a per-call-level scratch memory context. For the moment, the scratch context is just used to avoid leaking memory from datatype output function calls in PLyDict_FromTuple. There probably will be more use-cases in future. Although this is a fix for a pre-existing memory leakage bug, it seems sufficiently invasive to not want to back-patch; it feels better as part of the major rearrangement of plpython code that we've already done as part of 9.2. Jan Urbański
2012-02-01Code review for plpgsql fn_signature patch.Tom Lane
Don't quote the output of format_procedure(); it's already quoted quite enough. Remove the fn_name field, which was now just dead weight. Fix remaining expected-output files.
2012-01-31Adjust expected regression test outputs for PL/python.Robert Haas
This got broken by commit 4c6cedd1b014abf2046886a9a92e10e18f0d658e, which caused PL/pgsql error messages to print the function signature, not just the name. Per buildfarm.
2012-01-30PL/Python: Add result metadata functionsPeter Eisentraut
Add result object functions .colnames, .coltypes, .coltypmods to obtain information about the result column names and types, which was previously not possible in the PL/Python SPI interface. reviewed by Abhijit Menon-Sen
2012-01-10Fix typosPeter Eisentraut
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-12-29PL/Python: Add argument names to function declarationsPeter Eisentraut
For easier source reading
2011-12-27Run "make all" as a prerequisite of "make check"Peter Eisentraut
This is the standard behavior but was forgotten in some places.
2011-12-18PL/Python: One more file renaming fix to unbreak the buildPeter Eisentraut
2011-12-18Split plpython.c into smaller piecesPeter Eisentraut
This moves the code around from one huge file into hopefully logical and more manageable modules. For the most part, the code itself was not touched, except: PLy_function_handler and PLy_trigger_handler were renamed to PLy_exec_function and PLy_exec_trigger, because they were not actually handlers in the PL handler sense, and it makes the naming more similar to the way PL/pgSQL is organized. The initialization of the procedure caches was separated into a new function init_procedure_caches to keep the hash tables private to plpy_procedures.c. Jan Urbański and Peter Eisentraut
2011-12-15PL/Python: Refactor subtransaction handlingPeter Eisentraut
Lots of repetitive code was moved into new functions PLy_spi_subtransaction_{begin,commit,abort}. Jan Urbański
2011-12-05plpython: Add SPI cursor supportPeter Eisentraut
Add a function plpy.cursor that is similar to plpy.execute but uses an SPI cursor to avoid fetching the entire result set into memory. Jan Urbański, reviewed by Steve Singer
2011-11-29plpython: Fix sed expression in python3 buildPeter Eisentraut
The old expression sed 's,$(srcdir),python3,' would normally resolve as sed 's,.,python3,', which is not really what we wanted. While it doesn't actually break anything right now, it's still wrong, so put in a bit more work to make it more robust.
2011-11-24Preserve SQLSTATE when an SPI error is propagated through PL/pythonHeikki Linnakangas
exception handler. This was a regression in 9.1, when the capability to catch specific SPI errors was added, so backpatch to 9.1. Mika Eloranta, with some editing by Jan Urbański.