Re: plperl and inline functions -- first draft - Mailing list pgsql-hackers

From Alexey Klyukin
Subject Re: plperl and inline functions -- first draft
Date
Msg-id 246B7575-5825-4E48-BED6-4F63582727E8@waki.ru
Whole thread Raw
In response to Re: plperl and inline functions -- first draft  (Joshua Tolley <eggyknap@gmail.com>)
Responses Re: plperl and inline functions -- first draft
List pgsql-hackers
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) regression tests included
>
> 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 allow 'use Data::Dumper', and
> plperlu does. Since Data::Dumper is part of perl core, that seemed safe, but
> it is another dependency, and perhaps we don't want to do that. If not, is
> there some other useful way of testing plperlu vs. plperl, and does it really
> matter?

I've noticed that the patch doesn't install current_call_data before calling plperl_call_perl_func, although it saves
andrestores its previous value. This breaks spi code, which relies on current_call_data->prodesc, i.e.: 

postgres=# DO $$ $result = spi_exec_query("select 1"); $$ LANGUAGE plperl;

server closed the connection unexpectedlyThis probably means the server terminated abnormallybefore or while processing
therequest. 
The connection to the server was lost. Attempting reset: Failed.


rogram received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00000001006f0336 in plperl_spi_exec (query=0x1007ecb60 "select 1", limit=0) at plperl.c:1895
warning: Source file is more recent than executable.
1895            spi_rv = SPI_execute(query, current_call_data->prodesc->fn_readonly,
(gdb) bt
#0  0x00000001006f0336 in plperl_spi_exec (query=0x1007ecb60 "select 1", limit=0) at plperl.c:1895

Also, a call to to plperl_call_perl_func should be cast to void to avoid a possible compiler warning (although It
doesn'temit one on my system): 

(void) plperl_call_perl_func(&desc, &fake_fcinfo);

--
Alexey Klyukin                    http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc



pgsql-hackers by date:

Previous
From: Joshua Tolley
Date:
Subject: Re: plperl and inline functions -- first draft
Next
From: Dimitri Fontaine
Date:
Subject: Re: actualised funcs typmod patch