Re: [HACKERS] plperl and inline functions -- first draft

2009-11-29 Thread Joshua Tolley
On Sat, Nov 28, 2009 at 10:15:40PM -0500, Tom Lane wrote: > Joshua Tolley writes: > > Makes sense on both counts. Thanks for the help. How does the attached look? > > Applied with minor corrections, mainly around the state save/restore > logic. I also put in some code to fix the memory leak note

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-29 Thread Alexey Klyukin
On Nov 29, 2009, at 4:40 AM, Tom Lane wrote: > Alexey Klyukin writes: > >> Isn't it also the case with the existing plperl code ? I've noticed that >> free(prodesc) is called when it's no longer used (i.e. in >> plperl_compile_callback:1636), but refcount of desc->reference is never >> decre

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-28 Thread Tom Lane
Joshua Tolley writes: > Makes sense on both counts. Thanks for the help. How does the attached look? Applied with minor corrections, mainly around the state save/restore logic. I also put in some code to fix the memory leak noted by Tim Bunce, but am waiting for some confirmation that it's right

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-28 Thread Tom Lane
Alexey Klyukin writes: > On Nov 20, 2009, at 3:50 PM, Tim Bunce wrote: >> When does the reference held by desc.reference get freed? >> At the moment it looks like this would leak memory for each DO. > Isn't it also the case with the existing plperl code ? I've noticed that > free(prodesc) is cal

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-20 Thread David E. Wheeler
On Nov 20, 2009, at 10:50 PM, Tim Bunce wrote: > I'd suggest: > >...; PL/Perl functions created with CREATE FUNCTION are called in a >scalar context, so can't return a list. You can return more complex >structures (arrays, records, and sets) by returning a reference, as >discusse

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-20 Thread Alexey Klyukin
On Nov 20, 2009, at 3:50 PM, Tim Bunce wrote: > > When does the reference held by desc.reference get freed? > At the moment it looks like this would leak memory for each DO. Isn't it also the case with the existing plperl code ? I've noticed that free(prodesc) is called when it's no longer use

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-20 Thread Alexey Klyukin
On Nov 20, 2009, at 2:04 AM, Joshua Tolley wrote: > On Wed, Nov 18, 2009 at 12:38:00PM +0200, Alexey Klyukin wrote: >> Yes, current_call_data can't be allocate in the SPI memory context, since >> it's used to extract the result after SPI_finish is called, although it >> doesn't lead to problems

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-20 Thread Tim Bunce
On Thu, Nov 19, 2009 at 05:04:22PM -0700, Joshua Tolley wrote: > The body of the function is ordinary Perl code. In fact, the PL/Perl > !glue code wraps it inside a Perl subroutine. Anonymous code blocks cannot > !return a value; PL/Perl functions created with CREATE FUNCTION must > a

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-19 Thread Joshua Tolley
On Wed, Nov 18, 2009 at 12:38:00PM +0200, Alexey Klyukin wrote: > Yes, current_call_data can't be allocate in the SPI memory context, since > it's used to extract the result after SPI_finish is called, although it > doesn't lead to problems here since no result is returned. Anyway, I'd move > SP

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-18 Thread Alexey Klyukin
On Nov 18, 2009, at 5:46 AM, Andrew Dunstan wrote: > > > Joshua Tolley wrote: >> +plperl_call_data *save_call_data = current_call_data; >> +boololdcontext = trusted_context; >> + + if (SPI_connect() != SPI_OK_CONNECT) >> +elog(ERROR, "could not connect to SPI ma

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Andrew Dunstan
Joshua Tolley wrote: + plperl_call_data *save_call_data = current_call_data; + boololdcontext = trusted_context; + + if (SPI_connect() != SPI_OK_CONNECT) + elog(ERROR, "could not connect to SPI manager"); ... + current_call_data = (plperl_call

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Joshua Tolley
On Tue, Nov 17, 2009 at 06:05:19PM -0500, Andrew Dunstan wrote: > > > Alexey Klyukin wrote: >> >> I've noticed that the patch doesn't install current_call_data before calling >> plperl_call_perl_func, although it saves and restores its previous value. >> This breaks spi code, which relies on curr

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Andrew Dunstan
Alexey Klyukin wrote: I've noticed that the patch doesn't install current_call_data before calling plperl_call_perl_func, although it saves and restores its previous value. This breaks spi code, which relies on current_call_data->prodesc, i.e.: postgres=# DO $$ $result = spi_exec_query("sel

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Alexey Klyukin
On Nov 9, 2009, at 6:07 PM, Joshua Tolley wrote: > > Ok, updated patch attached. As far as I know, this completes all outstanding > issues: > > 1) weird comment in plperl.c is corrected and formatted decently > 2) plperlu vs. plperl actually works (thanks again, Andrew) > 3) docs included > 4) r

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Joshua Tolley
On Wed, Nov 18, 2009 at 09:35:35AM +1100, Brendan Jurd wrote: > 2009/11/17 Joshua Tolley : > > On Sun, Nov 15, 2009 at 12:10:33PM +1100, Brendan Jurd wrote: > >> I noticed that there was a fairly large amount of bogus/inconsistent > >> whitespace > ... > > > > Thanks -- I tend to forget whitespace

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-17 Thread Brendan Jurd
2009/11/17 Joshua Tolley : > On Sun, Nov 15, 2009 at 12:10:33PM +1100, Brendan Jurd wrote: >> I noticed that there was a fairly large amount of bogus/inconsistent >> whitespace ... > > Thanks -- I tend to forget whitespace :) > >> In the documentation you refer to this feature as "inline functions"

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-16 Thread Joshua Tolley
On Sun, Nov 15, 2009 at 12:10:33PM +1100, Brendan Jurd wrote: > I noticed that there was a fairly large amount of bogus/inconsistent > whitespace in the patch, particularly in the body of > plperl_inline_handler(). Some of the lines were indented with tabs, > others with spaces. You should stick

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-14 Thread Brendan Jurd
2009/11/10 Joshua Tolley : > Ok, updated patch attached. As far as I know, this completes all outstanding > issues: > Hi Joshua, I'm taking a look at this patch for the commitfest. I see that Andrew has already taken an interest in the technical aspects of the patch, so I'll focus on submission/

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-13 Thread Andrew Dunstan
Joshua Tolley wrote: Some items of note include that this makes the regression tests add not only plperl to the test database but also plperlu, which is a new thing. I can't see why this might cause problems, but thought I'd mention it. The tests specifically try to verify that plperl doesn't a

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-12 Thread Joshua Tolley
On Fri, Nov 06, 2009 at 09:53:20PM -0500, Andrew Dunstan wrote: > Joshua Tolley wrote: >> I looked through the >> regression tests and didn't find any that used plperl -- should we add one >> for >> this (or for this and all kinds of other stuff)? Is there some way to make >> running the regressi

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-09 Thread Joshua Tolley
On Fri, Nov 06, 2009 at 09:53:20PM -0500, Andrew Dunstan wrote: > > > Joshua Tolley wrote: >> I looked through the >> regression tests and didn't find any that used plperl -- should we add one >> for >> this (or for this and all kinds of other stuff)? Is there some way to make >> running the regr

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-05 Thread Joshua Tolley
On Thu, Nov 05, 2009 at 05:51:45PM -0500, Andrew Dunstan wrote: > Joshua Tolley wrote: >> I've been trying to make pl/perl support 8.5's inline functions, with the >> attached patch. > > Wow, this is the second time this week that people have produced patches > for stuff I was about to do. Cool!

Re: [HACKERS] plperl and inline functions -- first draft

2009-11-05 Thread Andrew Dunstan
Joshua Tolley wrote: I've been trying to make pl/perl support 8.5's inline functions, with the attached patch. Wow, this is the second time this week that people have produced patches for stuff I was about to do. Cool! The basics seem to be there, with at least one notable exception, nam

[HACKERS] plperl and inline functions -- first draft

2009-11-05 Thread Joshua Tolley
I've been trying to make pl/perl support 8.5's inline functions, with the attached patch. The basics seem to be there, with at least one notable exception, namely that plperl functions can do stuff only plperlu should do. I presume this is because I really don't understand yet how plperl's trusted