Re: Segfault from PL/Perl Returning vstring

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: Segfault from PL/Perl Returning vstring
Дата
Msg-id 4B2FD089.6060101@dunslane.net
обсуждение исходный текст
Ответ на Segfault from PL/Perl Returning vstring  ("David E. Wheeler" <david@kineticode.com>)
Ответы Re: Segfault from PL/Perl Returning vstring  ("David E. Wheeler" <david@kineticode.com>)
Re: Segfault from PL/Perl Returning vstring  (Peter Eisentraut <peter_e@gmx.net>)
Re: Segfault from PL/Perl Returning vstring  (Tim Bunce <Tim.Bunce@pobox.com>)
Список pgsql-hackers

David E. Wheeler wrote:
> At least I think it's a segfault. This function returns a vstring:
>
> CREATE OR REPLACE FUNCTION wtf(
> ) RETURNS text LANGUAGE plperl IMMUTABLE STRICT AS $X$
>     return $^V;
> $X$;
>
> Here's what happens when I call it:
>
> try=# select wtf();
> server closed the connection unexpectedly
>     This probably means the server terminated abnormally
>     before or while processing the request.
> The connection to the server was lost. Attempting reset: Failed.
> !>
>
> So I think that it doesn't know what to do with vstrings. They should probably never be returned (they're mostly
deprecated),but if they are, they should be cast to text, I think.
 
>
>
>   

It's not doing that for me.

The plperl code has no way at all of knowing that the bytes you are 
returning come from $^V. If you really want the version back, do what 
the perl docs tell you and sprintf the value:
   andrew=# CREATE OR REPLACE FUNCTION wtf(   ) RETURNS text LANGUAGE plperl IMMUTABLE STRICT AS $X$       return
sprintf("%vd",$^V);  $X$;   CREATE FUNCTION   andrew=# select wtf();     wtf    -------    5.8.8
 

BTW, this should arguably not be an immutable function. You could 
replace the perl library, so it's not solely dependent on the input for 
the result.

cheers

andrew




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

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Segfault from PL/Perl Returning vstring
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Segfault from PL/Perl Returning vstring