Re: pgsql: Transforms for jsonb to PL/Perl
От | Tom Lane |
---|---|
Тема | Re: pgsql: Transforms for jsonb to PL/Perl |
Дата | |
Msg-id | 30494.1522851983@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: pgsql: Transforms for jsonb to PL/Perl (Anthony Bykov <a.bykov@postgrespro.ru>) |
Ответы |
Re: pgsql: Transforms for jsonb to PL/Perl
|
Список | pgsql-committers |
Anthony Bykov <a.bykov@postgrespro.ru> writes: > Tom Lane <tgl@sss.pgh.pa.us> wrote: >> This results in one change in the module's test results: the example >> that thinks it's returning a regexp match result no longer fails, >> but just returns the scalar result (0). I'm inclined to think that >> this is correct/desirable and the existing behavior is an accidental >> artifact of not coping with Perl's various augmented representations >> of scalar values. > I think that there is a mistake in test: > CREATE FUNCTION testRegexpToJsonb() RETURNS jsonb > LANGUAGE plperl > TRANSFORM FOR TYPE jsonb > AS $$ > return ('1' =~ m(0\t2)); > $$; > =~ is the operator testing a regular expression match. > Hence, testRegexpToJsonb function returns true/false values > (when used in scalar context, the return value > generally indicates the success of the operation). Right, that was my point: this is returning a scalar result that just happens to have been derived from a regexp match. So the output ought to be 1 or 0, and the fact that (on some platforms?) it isn't represents a bug. > I guess the right test will look a little bit different: > CREATE FUNCTION testRegexpToJsonb() RETURNS jsonb > LANGUAGE plperl > TRANSFORM FOR TYPE jsonb > AS $$ > $a = qr//; > return ($a); > $$; This is testing something else. I don't object to adding it, but we should keep the existing test in some form to verify that the bug stays fixed. regards, tom lane
В списке pgsql-committers по дате отправления: