| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
Lots of repetitive code was moved into new functions
PLy_spi_subtransaction_{begin,commit,abort}.
Jan Urbański
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rewrite plancache.c so that a "cached plan" (which is rather a misnomer
at this point) can support generation of custom, parameter-value-dependent
plans, and can make an intelligent choice between using custom plans and
the traditional generic-plan approach. The specific choice algorithm
implemented here can probably be improved in future, but this commit is
all about getting the mechanism in place, not the policy.
In addition, restructure the API to greatly reduce the amount of extraneous
data copying needed. The main compromise needed to make that possible was
to split the initial creation of a CachedPlanSource into two steps. It's
worth noting in particular that SPI_saveplan is now deprecated in favor of
SPI_keepplan, which accomplishes the same end result with zero data
copying, and no need to then spend even more cycles throwing away the
original SPIPlan. The risk of long-term memory leaks while manipulating
SPIPlans has also been greatly reduced. Most of this improvement is based
on use of the recently-added MemoryContextSetParent primitive.
|
|
|
|
|
|
|
| |
Module initialization functions in Python 3 must have external
linkage, because PyMODINIT_FUNC does dllexport on Windows-like
platforms. Without this change, the build with Python 3 fails on
Windows.
|
| |
|
|
|
|
|
|
|
|
| |
Dropped columns within a composite type were not handled correctly.
Also, we did not check for whether a composite result type had changed
since we cached the information about it.
Jan Urbański, per a bug report from Jean-Baptiste Quenot
|
|
|
|
|
|
|
|
| |
To avoid having the python headers hijack various definitions,
we now include them after all the system headers we want, having
first undefined some of the things they want to define. After that's
done we restore the things they scribbled on that matter, namely our
snprintf and vsnprintf macros, if we're using them.
|
|
|
|
|
|
| |
There may be some other places where we should use errdetail_internal,
but they'll have to be evaluated case-by-case. This commit just hits
a bunch of places where invoking gettext is obviously a waste of cycles.
|
|
|
|
|
| |
This lets us stop including rel.h into execnodes.h, which is a widely
used header.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
printf type functions.
The style is set to "printf" for backwards compatibility everywhere except
on Windows, where it is set to "gnu_printf", which eliminates hundreds of
false error messages from modern versions of gcc arising from %m and %ll{d,u}
formats.
|
|
|
|
|
|
|
|
|
|
|
|
| |
It assumed that the lineno from the traceback always refers to the
PL/Python function. If you created a PL/Python function that imports
some code, runs it, and that code raises an exception, PLy_traceback
would get utterly confused.
Now we look at the file name reported with the traceback and only
print the source line if it came from the PL/Python function.
Jan Urbański
|
| |
|
|
|
|
| |
Jan Urbański
|
|
|
|
|
|
|
| |
This mimics the traceback information the Python interpreter prints
with exceptions.
Jan Urbański
|
|
|
|
|
|
| |
blocks.
Investigation by Jan Urbański, though I didn't use his patch.
|
|
|
|
|
| |
Report and patch from Daniel Popowich, bug #5842
(with some debugging help from Alex Hunsaker)
|
|
|
|
|
|
|
| |
It should cause a elog(FATAL) error, and it fact it was simply causing
a elog(ERROR).
Jan Urbański
|
|
|
|
|
|
|
|
|
|
| |
This improves reporting, as the error string now includes the actual
Python exception. As a side effect, this no longer sets the errcode to
ERRCODE_DATA_EXCEPTION, which might be considered a feature, as it's
not documented and not clear why iterator errors should be treated
differently.
Jan Urbański
|
|
|
|
|
|
| |
Seen with an older gcc version. I'm not sure these represent any real
risk factor, but still a bit scary. Anyway we have lots of other
volatile-marked variables in this code, so a couple more won't hurt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This mostly just involves creating control, install, and
update-from-unpackaged scripts for them. However, I had to adjust plperl
and plpython to not share the same support functions between variants,
because we can't put the same function into multiple extensions.
catversion bump forced due to new contents of pg_pltemplate, and because
initdb now installs plpgsql as an extension not a bare language.
Add support for regression testing these as extensions not bare
languages.
Fix a couple of other issues that popped up while testing this: my initial
hack at pg_dump binary-upgrade support didn't work right, and we don't want
an extra schema permissions test after all.
Documentation changes still to come, but I'm committing now to see
whether the MSVC build scripts need work (likely they do).
|
|
|
|
| |
Mostly text supplied by Jan Urbański.
|
|
|
|
| |
Patch from Jan Urbański.
|
|
|
|
|
|
|
|
| |
This provides a separate exception class for each error code that the
backend defines, as well as the ability to get the SQLSTATE from the
exception object.
Jan Urbański, reviewed by Steve Singer
|
|
|
|
|
|
|
| |
Adds a context manager, obtainable by plpy.subtransaction(), to run a
group of statements in a subtransaction.
Jan Urbański, reviewed by Steve Singer, additional scribbling by me
|
|
|
|
|
|
|
| |
This allows functions with multiple OUT parameters returning both one
or multiple records (RECORD or SETOF RECORD).
Jan Urbański, reviewed by Hitoshi Harada
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add functions plpy.quote_ident, plpy.quote_literal,
plpy.quote_nullable, which wrap the equivalent SQL functions.
To be able to propagate char * constness properly, make the argument
of quote_literal_cstr() const char *. This also makes it more
consistent with quote_identifier().
Jan Urbański, reviewed by Hitoshi Harada, some refinements by Peter
Eisentraut
|
|
|
|
|
|
|
|
|
| |
type changes.
The invalidation will cause the type information to be refetched, and
everything will work.
Jan Urbański, reviewed by Alex Hunsaker
|
|
|
|
|
| |
The first argument of PyEval_EvalCode() was changed from PyCodeObject*
to PyObject* because of PEP 384.
|
|
|
|
|
|
|
|
|
|
|
| |
This allows the language-specific try/catch construct to catch and
handle exceptions arising from SPI calls, matching the behavior of
other PLs.
As an additional bonus you no longer get all the ugly "unrecognized
error in PLy_spi_execute_query" errors.
Jan Urbański, reviewed by Steve Singer
|
|
|
|
| |
Jan Urbański, reviewed by Hitoshi Harada
|
|
|
|
|
|
| |
It is redundant, given the error context.
Jan Urbański
|
|
|
|
|
|
|
|
|
|
| |
Use the built-in TypeError, not SPIError, for errors having to do with
argument counts or types. Use SPIError, not simply plpy.Error, for
errors in PLy_spi_execute_plan. Finally, do not set a Python
exception if PyArg_ParseTuple failed, as it already sets the correct
exception.
Jan Urbański
|
|
|
|
|
|
|
| |
The temporarily broken plpython_unicode test shows a case where this
is used.
Do remaining fix-ups on the expected files at the same time.
|
|
|
|
|
| |
Older versions of GCC appear to report these with the current standard
option set, newer versions need -Wformat-security.
|
|
|
|
|
|
|
| |
This way errors from fetching tuples are correctly reported as errors
in the SPI call. While at it, avoid palloc(0).
Jan Urbański
|
|
|
|
|
|
|
| |
Instead of checking whether the arglist is NULL and then if its length
is 0, do it in one step, and outside of the try/catch block.
Jan Urbański
|
|
|
|
|
|
|
|
| |
This reverts commit 740e54ca84c437fd67524f97a3ea9ddea752e208, which seems
to have tickled an optimization bug in gcc 4.5.x, as reported upstream at
https://bugzilla.redhat.com/show_bug.cgi?id=671899
Since this patch had no purpose beyond code beautification, it's not
worth expending a lot of effort to look for another workaround.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Global error handling led to confusion and was hard to manage. With
this change, errors from PostgreSQL are immediately reported to Python
as exceptions. This requires setting a Python exception after
reporting the caught PostgreSQL error as a warning, because PLy_elog
destroys the Python exception state.
Ideally, all places where PostgreSQL errors need to be reported back
to Python should be wrapped in subtransactions, to make going back to
Python from a longjmp safe. This will be handled in a separate patch.
Jan Urbański
|
|
|
|
|
|
|
|
|
|
| |
The way the exception types where added to the module was wrong for
Python 3. Exception classes were not actually available from plpy.
Fix that by factoring out code that is responsible for defining new
Python exceptions and make it work with Python 3. New regression test
makes sure the plpy module has the expected contents.
Jan Urbanśki, slightly revised by me
|
|
|
|
| |
Hitoshi Harada
|
|
|
|
| |
Hitoshi Harada
|
|
|
|
|
|
| |
This makes PLy_procedure_create a bit more manageable.
Jan Urbański
|
|
|
|
| |
Jan Urbański, reviewed by Peter Eisentraut, Álvaro Herrera, Tom Lane :-)
|
|
|
|
| |
Jan Urbański
|
|
|
|
|
|
| |
The previous code would try to print out a null pointer.
Jan Urbański
|
|
|
|
|
|
| |
The latter is undocumented and the speed gain is negligible.
Jan Urbański
|