| From: | Alexey Klyukin <alexk(at)commandprompt(dot)com> |
|---|---|
| To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Cc: | Joshua Tolley <eggyknap(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: plperl and inline functions -- first draft |
| Date: | 2009-11-18 10:38:00 |
| Message-ID: | E072FC9F-B9FB-4EB7-94CC-9B8EE8ED98D7@commandprompt.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Nov 18, 2009, at 5:46 AM, Andrew Dunstan wrote:
>
>
> Joshua Tolley wrote:
>> + plperl_call_data *save_call_data = current_call_data;
>> + bool oldcontext = trusted_context;
>> + + if (SPI_connect() != SPI_OK_CONNECT)
>> + elog(ERROR, "could not connect to SPI manager");
>>
> ...
>> + current_call_data = (plperl_call_data *) palloc0(sizeof(plperl_call_data));
>> + current_call_data->fcinfo = &fake_fcinfo;
>> + current_call_data->prodesc = &desc;
>>
>
> I don't think this is done in the right order. If it is then this comment in plperl_func_handler is wrong (as well as containing a typo):
>
> /*
> * Create the call_data beforing connecting to SPI, so that it is not
> * allocated in the SPI memory context
> */
>
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 SPI_connect after the current_call_data initialization.
I also noticed that no error context is set in the inline handler, not sure whether it really useful except for the sake of consistency, but in case it is - here is the patch:
| Attachment | Content-Type | Size |
|---|---|---|
| inline_callback.diff | application/octet-stream | 2.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2009-11-18 10:46:02 | Re: RFC for adding typmods to functions |
| Previous Message | Albe Laurenz | 2009-11-18 10:35:22 | Re: Rejecting weak passwords |