aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plperl/expected/jsonb_plperl.out
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-04-04 11:28:33 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-04-04 11:28:40 -0400
commit331b2369c0ad1e51d5e50bf5dd75232e0160553a (patch)
treec4664e95d32549da837b34db0b1305773618c7c9 /contrib/jsonb_plperl/expected/jsonb_plperl.out
parent3a5e0a91bb324ad2b2b1a0623a3f2e37772b43fc (diff)
downloadpostgresql-331b2369c0ad1e51d5e50bf5dd75232e0160553a.tar.gz
postgresql-331b2369c0ad1e51d5e50bf5dd75232e0160553a.zip
Fix platform and Perl-version dependencies in new jsonb_plperl code.
Testing SvTYPE() directly is more fraught with problems than one might think, because depending on context Perl might be storing a scalar value in one of several forms, eg both numeric and string values. This resulted in Perl-version-dependent buildfarm test failures. Instead use the SvTYPE test only to distinguish non-scalar cases (AV, HV, NULL). Disambiguate scalars by testing SvIOK, SvNOK, then SvPOK. This creates a preference order for how we will resolve cases where the value is available in more than one form, which seems fine to me. Furthermore, because we're now dealing directly with a "double" value in the SvNOK case, we can get rid of an inadequate and unportable string-comparison test for infinities, and use isinf() instead. (We do need some additional #include and "-lm" infrastructure to use that in a contrib module, per prior experiences.) In passing, prevent the regression test results from depending on DROP CASCADE order; I've not seen that malfunction, but it's trouble waiting to happen. Discussion: https://postgr.es/m/E1f3MMJ-0006bf-B0@gemulon.postgresql.org
Diffstat (limited to 'contrib/jsonb_plperl/expected/jsonb_plperl.out')
-rw-r--r--contrib/jsonb_plperl/expected/jsonb_plperl.out26
1 files changed, 18 insertions, 8 deletions
diff --git a/contrib/jsonb_plperl/expected/jsonb_plperl.out b/contrib/jsonb_plperl/expected/jsonb_plperl.out
index 5bb5677f711..79d53e5e50f 100644
--- a/contrib/jsonb_plperl/expected/jsonb_plperl.out
+++ b/contrib/jsonb_plperl/expected/jsonb_plperl.out
@@ -39,15 +39,30 @@ SELECT testSVToJsonb();
1
(1 row)
+-- unsupported (for now)
CREATE FUNCTION testRegexpToJsonb() RETURNS jsonb
LANGUAGE plperl
TRANSFORM FOR TYPE jsonb
AS $$
-return ('1' =~ m(0\t2));
+my $a = qr/foo/;
+return ($a);
$$;
SELECT testRegexpToJsonb();
ERROR: cannot transform this Perl type to jsonb
CONTEXT: PL/Perl function "testregexptojsonb"
+-- this revealed a bug in the original implementation
+CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
+LANGUAGE plperl
+TRANSFORM FOR TYPE jsonb
+AS $$
+return ('1' =~ m(0\t2));
+$$;
+SELECT testRegexpResultToJsonb();
+ testregexpresulttojsonb
+-------------------------
+ 0
+(1 row)
+
CREATE FUNCTION roundtrip(val jsonb) RETURNS jsonb
LANGUAGE plperl
TRANSFORM FOR TYPE jsonb
@@ -201,11 +216,6 @@ SELECT roundtrip('{"1": {"2": [3, 4, 5]}, "2": 3}');
{"1": {"2": [3, 4, 5]}, "2": 3}
(1 row)
+\set VERBOSITY terse \\ -- suppress cascade details
DROP EXTENSION plperl CASCADE;
-NOTICE: drop cascades to 6 other objects
-DETAIL: drop cascades to extension jsonb_plperl
-drop cascades to function testhvtojsonb()
-drop cascades to function testavtojsonb()
-drop cascades to function testsvtojsonb()
-drop cascades to function testregexptojsonb()
-drop cascades to function roundtrip(jsonb)
+NOTICE: drop cascades to 7 other objects