From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anthony Bykov <a.bykov@postgrespro.ru>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Transforms for jsonb to PL/Perl
Date: Wed, 04 Apr 2018 10:26:23 -0400
Message-ID: <30494.1522851983@sss.pgh.pa.us> (raw)
In-Reply-To: <20180404161144.37d03301@anthony-24-g082ur>
References: <E1f3MMJ-0006bf-B0@gemulon.postgresql.org>
<13723.1522768121@sss.pgh.pa.us>
<3001.1522769607@sss.pgh.pa.us>
<15089.1522791424@sss.pgh.pa.us>
<20180404161144.37d03301@anthony-24-g082ur>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, a.bykov@postgrespro.ru, peter_e@gmx.net
Subject: Re: pgsql: Transforms for jsonb to PL/Perl
In-Reply-To: <30494.1522851983@sss.pgh.pa.us>
References: <E1f3MMJ-0006bf-B0@gemulon.postgresql.org> <13723.1522768121@sss.pgh.pa.us> <3001.1522769607@sss.pgh.pa.us> <15089.1522791424@sss.pgh.pa.us> <20180404161144.37d03301@anthony-24-g082ur> <30494.1522851983@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox