From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Anthony Bykov <a(dot)bykov(at)postgrespro(dot)ru> |
Cc: | Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | Re: pgsql: Transforms for jsonb to PL/Perl |
Date: | 2018-04-04 14:26:23 |
Message-ID: | 30494.1522851983@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Anthony Bykov <a(dot)bykov(at)postgrespro(dot)ru> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-04-04 15:28:57 | pgsql: Fix platform and Perl-version dependencies in new jsonb_plperl c |
Previous Message | Alvaro Herrera | 2018-04-04 13:47:32 | Re: pgsql: Validate page level checksums in base backups |