Re: PL/Perl Does not Like vstrings

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: PL/Perl Does not Like vstrings
Дата
Msg-id 4F05E2D6.2060305@dunslane.net
обсуждение исходный текст
Ответ на Re: PL/Perl Does not Like vstrings  ("David E. Wheeler" <david@justatheory.com>)
Ответы Re: PL/Perl Does not Like vstrings  ("David E. Wheeler" <david@justatheory.com>)
Re: PL/Perl Does not Like vstrings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On 01/05/2012 12:28 PM, David E. Wheeler wrote:
> On Jan 5, 2012, at 7:34 AM, Tom Lane wrote:
>
>>> That still crashes, but doesn't if we use sv_mortalcopy unconditionally.
>> Unconditional sv_mortalcopy sounds like the thing to do then, but a
>> comment would help.  And if this isn't a Perl bug, I would like to
>> know what is.
> Question: Is this an issue anywhere else in PL/Perl, or just elog()? What about SPI parameters or return values?


The fix that has been applied, as Tom suggested, is at the point where
we call SvPVutf8(), so that's not just for elog().


>
> david=# DO LANGUAGE PLPERL $$
> david$#     my $plan = spi_prepare('SELECT $1', 'TEXT');
> david$#     spi_query_prepared($plan, $^V);
> david$#     spi_freeplan($plan);
> david$#     return;
> david$# $$;
> ERROR:  cannot convert Perl hash to non-composite type text at line 3.
> CONTEXT:  PL/Perl anonymous code block
>
> No segfault, at least, though that’s a rather bizarre error message. AFAIK, $^V isn’t a hash. This works, though:


As documented, it's not a scalar, and you need to stop treating it as
one. If you want it as a scalar, which is what you'd need here, enclose
it in quotes, or use the stuff shown in perldoc perlvar.


cheers

andrew





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PL/Perl Does not Like vstrings
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: PL/Perl Does not Like vstrings