summaryrefslogtreecommitdiff
path: root/src/pl/plperl/plperl.c
AgeCommit message (Collapse)Author
2008-01-22Work around for perl 5.10 bug - fix due to perl hacker Simon Cozens.Andrew Dunstan
2007-12-01Suppress compiler warnings in recent plperl patch. Avoid uselessly expensiveTom Lane
lookup of the well-known OID of textout().
2007-12-01Workaround for perl problem where evaluating UTF8 regexes can causeAndrew Dunstan
implicit loading of modules, thereby breaking Safe rules. We compile and call a tiny perl function on trusted interpreter init, after which the problem does not occur.
2007-06-28Fix incorrect tests for undef Perl values in some places in plperl.c.Tom Lane
The correct test for defined-ness is SvOK(sv), not anything involving SvTYPE. Per bug #3415 from Matt Taylor. Back-patch as far as 8.0; no apparent problem in 7.x.
2006-11-21remove duplicate declaration, per report from Magnus Hagander.Andrew Dunstan
2006-11-13Force plperl and plperlu to run in separate interpreters. Create an errorAndrew Dunstan
on an attempt to create the second interpreter if this is not supported by the perl installation. Per recent -hackers discussion.
2006-10-19Clean up local redeclarations of variables with DLLIMPORT, per reportTom Lane
from Magnus that MSVC complains about this.
2006-10-15Adjust plperl to ensure that all strings and hash keys passed to PerlTom Lane
are marked as UTF8 when the database encoding is UTF8. This should avoid inconsistencies like that exhibited in bug #2683 from Vitali Stupin.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-08-27Add new return codes SPI_OK_INSERT_RETURNING etc to the SPI API.Tom Lane
Fix all the standard PLs to be able to return tuples from FOO_RETURNING statements as well as utility statements that return tuples. Also, fix oversight that SPI_processed wasn't set for a utility statement returning tuples. Per recent discussion.
2006-08-13Back out plperl OUT hash/array parameter patch, again.Bruce Momjian
2006-08-13Re-apply plperl patch that allows OUT parameters to be placed into PerlBruce Momjian
hash and array variables. (regression output updated)
2006-08-12Back out patch for plperl to handle OUT paramaters into arrays andBruce Momjian
hashes. Was causing regression failures.
2006-08-11plperl:Bruce Momjian
Allow conversion from perl to postgresql array in OUT parameters. Second, allow hash form output from procedures with one OUT argument. Pavel Stehule
2006-08-08Add a feature for automatic initialization and finalization of dynamicallyTom Lane
loaded libraries: call functions _PG_init() and _PG_fini() if the library defines such symbols. Hence we no longer need to specify an initialization function in preload_libraries: we can assume that the library used the _PG_init() convention, instead. This removes one source of pilot error in use of preloaded libraries. Original patch by Ralf Engelschall, preload_libraries changes by me.
2006-06-16Fix problems with cached tuple descriptors disappearing while still in useTom Lane
by creating a reference-count mechanism, similar to what we did a long time ago for catcache entries. The back branches have an ugly solution involving lots of extra copies, but this way is more efficient. Reference counting is only applied to tupdescs that are actually in caches --- there seems no need to use it for tupdescs that are generated in the executor, since they'll go away during plan shutdown by virtue of being in the per-query memory context. Neil Conway and Tom Lane
2006-05-30Magic blocks don't do us any good unless we use 'em ... so install oneTom Lane
in every shared library.
2006-05-29Make plperl's $_TD trigger data a global rather than a lexical variable,Andrew Dunstan
with a fresh local value for each invocation, to avoid unexpected sharing violations. Per recent -hackers discussion.
2006-05-26Add table_name and table_schema to plperl trigger data. relname isAndrew Dunstan
kept but now deprecated. Patch from Adam Sjøgren. Add regression test to show plperl trigger data (Andrew). TBD: apply similar changes to plpgsql, plpython and pltcl.
2006-04-04Modify all callers of datatype input and receive functions so that if theseTom Lane
functions are not strict, they will be called (passing a NULL first parameter) during any attempt to input a NULL value of their datatype. Currently, all our input functions are strict and so this commit does not change any behavior. However, this will make it possible to build domain input functions that centralize checking of domain constraints, thereby closing numerous holes in our domain support, as per previous discussion. While at it, I took the opportunity to introduce convenience functions InputFunctionCall, OutputFunctionCall, etc to use in code that calls I/O functions. This eliminates a lot of grotty-looking casts, but the main motivation is to make it easier to grep for these places if we ever need to touch them again.
2006-03-19Fix a few places that were checking for the return value of palloc() to beNeil Conway
non-NULL: palloc() ereports on OOM, so we can safely assume it returns a valid pointer.
2006-03-14Improve parser so that we can show an error cursor position for errorsTom Lane
during parse analysis, not only errors detected in the flex/bison stages. This is per my earlier proposal. This commit includes all the basic infrastructure, but locations are only tracked and reported for errors involving column references, function calls, and operators. More could be done later but this seems like a good set to start with. I've also moved the ReportSyntaxErrorPosition logic out of psql and into libpq, which should make it available to more people --- even within psql this is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
2006-03-11Remove copyright notices from Jan (per author approval), and those filesBruce Momjian
derived from Jan's.
2006-03-05Prepared queries for PLPerl, plus fixing a small plperl memory leak. PatchAndrew Dunstan
and docs from Dmitry Karasik, slightly editorialised.
2006-02-28Fix typo in comment.Neil Conway
2006-02-26Fix a few minor typos in comments in PL/Perl.Neil Conway
2006-01-28Undo perl's nasty locale setting on Windows. Since we can't do that asAndrew Dunstan
elsewhere by setting the environment appropriately, we make perl do it right after interpreter startup by calling its POSIX::setlocale().
2006-01-28Per a bug report from Theo Schlossnagle, plperl_return_next() leaksNeil Conway
memory in the executor's per-query memory context. It also inefficient: it invokes get_call_result_type() and TupleDescGetAttInMetadata() for every call to return_next, rather than invoking them once (per PL/Perl function call) and memoizing the result. This patch makes the following changes: - refactor the code to include all the "per PL/Perl function call" data inside a single struct, "current_call_data". This means we don't need to save and restore N pointers for every recursive call into PL/Perl, we can just save and restore one. - lookup the return type metadata needed by plperl_return_next() once, and then stash it in "current_call_data", so as to avoid doing the lookup for every call to return_next. - create a temporary memory context in which to evaluate the return type's input functions. This memory context is reset for each call to return_next. The patch appears to fix the memory leak, and substantially reduces the overhead imposed by return_next.
2006-01-08Rationalise perl header inclusions via a common include file, which alsoAndrew Dunstan
declares routines in plperl.c and spi_internal.c used in other files. Along the way, also stop perl from hijacking stdio and other stuff on Windows.
2005-12-29Move declaration of check_function_bodies to where the perl headersAndrew Dunstan
haven't had a chance to mangle the definition of DLLIMPORT (thanks again, perl guys).
2005-12-28Fix plperl validator to honor check_function_bodies: when that is OFF,Tom Lane
we want it to check the argument/result data types and no more. In particular, libperl shouldn't get initialized in this case.
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). Backpatch to 8.1.X.
2005-11-18translate undef to NULL for result arrayref, now that we allow NULLs in ↵Andrew Dunstan
arrays. Update plperl regression test accordingly.
2005-10-18Code review for spi_query/spi_fetchrow patch: handle errors sanely,Tom Lane
avoid leaking memory. I would add a regression test for error handling except it seems eval{} can't be used in unprivileged plperl :-(
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-08-24Get rid of inappropriate use of croak(). Per report from Michael Fuhr.Tom Lane
2005-08-24Fix up plperl 'use_strict' so that it can be enabled or disabled on theTom Lane
fly. Fix problem with incompletely duplicated setup code. Andrew Dunstan, from an idea of Michael Fuhr's.
2005-08-20Invoke mksafefunc and mkunsafefunc with :: decoration. This seems a goodTom Lane
idea on consistency grounds, whether or not it really fixes bug #1831. Michael Fuhr
2005-08-12Un-break plperl for non-set case.Tom Lane
2005-08-12More rsi assignment line too.Bruce Momjian
2005-08-12> The attached patch moves a plperl sanity check into the correctBruce Momjian
> position. Performing the check in the existing position allows the call > to go through to perl first, possibly resulting in a SEGV. Andrew Dunstan
2005-07-12Fix plperl crash with list value return for an array result type.Tom Lane
Reported by Michael Fuhr, fixed by Andrew Dunstan.
2005-07-12Fix plperl to do recursion safely, and fix a problem with array results.Tom Lane
Add suitable regression tests. Andrew Dunstan
2005-07-10Rename xmalloc to pg_malloc for consistency with psql usage.Bruce Momjian
Add missing plperl include.
2005-07-10Following up a previous thought I had, yesterday I realised how toBruce Momjian
return arays nicely without having to make the plperl programmer aware of anything. The attached patch allows plperl to return an arrayref where the function returns an array type. It silently calls a perl function to stringify the array before passing it to the pg array parser. Non-array returns are handled as before (i.e. passed through this process) so it is backwards compatible. I will presently submit regression tests and docs. example: andrew=# create or replace function blah() returns text[][] language plperl as $$ return [['a"b','c,d'],['e\\f','g']]; $$; CREATE FUNCTION andrew=# select blah(); blah ----------------------------- {{"a\"b","c,d"},{"e\\f",g}} This would complete half of the TODO item: . Pass arrays natively instead of as text between plperl and postgres (The other half is translating pg array arguments to perl arrays - that will have to wait for 8.1). Some of this patch is adapted from a previously submitted patch from Sergej Sergeev. Both he and Abhijit Menon-Sen have looked it over briefly and tentatively said it looks ok. Andrew Dunstan
2005-07-10The attached patch implements spi_query() and spi_fetchrow() functionsBruce Momjian
for PL/Perl, to avoid loading the entire result set into memory as the existing spi_exec_query() function does. Here's how one might use the new functions: $x = spi_query("select ..."); while (defined ($y = spi_fetchrow($x))) { ... return_next(...); } The changes do not affect the spi_exec_query() interface in any way. Abhijit Menon-Sen
2005-07-06Currently, nonfatal warnings are not trapped (as they should be) byBruce Momjian
plperl - the attached small patch remedies that omission, and adds a small regression test for error and warning output - the new regression input and expected output are in separate attached files. Andrew Dunstan
2005-07-06Currently, nonfatal warnings are not trapped (as they should be) byBruce Momjian
plperl - the attached small patch remedies that omission. Andrew Dunstan
2005-07-03Fix memory leak in plperl_hash_from_tuple(), per report from Jean-Max Reymond.Tom Lane
2005-06-22Add a validator function for plperl. Andrew DunstanTom Lane