mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Fix jsonb_plperl to convert Perl UV values correctly.
Values greater than IV_MAX were incorrectly converted to SQL, for instance ~0 would become -1 rather than 18446744073709551615 (on a 64-bit machine). Dagfinn Ilmari Mannsåker, adjusted a bit by me Discussion: https://postgr.es/m/d8jtvskjzzs.fsf@dalvik.ping.uio.no
This commit is contained in:
@ -39,6 +39,20 @@ SELECT testSVToJsonb();
|
||||
1
|
||||
(1 row)
|
||||
|
||||
CREATE FUNCTION testUVToJsonb() RETURNS jsonb
|
||||
LANGUAGE plperl
|
||||
TRANSFORM FOR TYPE jsonb
|
||||
as $$
|
||||
$val = ~0;
|
||||
return $val;
|
||||
$$;
|
||||
-- this might produce either 18446744073709551615 or 4294967295
|
||||
SELECT testUVToJsonb() IN ('18446744073709551615'::jsonb, '4294967295'::jsonb);
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- this revealed a bug in the original implementation
|
||||
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
|
||||
LANGUAGE plperl
|
||||
@ -216,4 +230,4 @@ SELECT roundtrip('{"1": {"2": [3, 4, 5]}, "2": 3}', 'HASH');
|
||||
|
||||
\set VERBOSITY terse \\ -- suppress cascade details
|
||||
DROP EXTENSION plperl CASCADE;
|
||||
NOTICE: drop cascades to 6 other objects
|
||||
NOTICE: drop cascades to 7 other objects
|
||||
|
@ -39,6 +39,20 @@ SELECT testSVToJsonb();
|
||||
1
|
||||
(1 row)
|
||||
|
||||
CREATE FUNCTION testUVToJsonb() RETURNS jsonb
|
||||
LANGUAGE plperlu
|
||||
TRANSFORM FOR TYPE jsonb
|
||||
as $$
|
||||
$val = ~0;
|
||||
return $val;
|
||||
$$;
|
||||
-- this might produce either 18446744073709551615 or 4294967295
|
||||
SELECT testUVToJsonb() IN ('18446744073709551615'::jsonb, '4294967295'::jsonb);
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- this revealed a bug in the original implementation
|
||||
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
|
||||
LANGUAGE plperlu
|
||||
@ -243,4 +257,4 @@ INFO: $VAR1 = {'1' => {'2' => ['3','4','5']},'2' => '3'};
|
||||
|
||||
\set VERBOSITY terse \\ -- suppress cascade details
|
||||
DROP EXTENSION plperlu CASCADE;
|
||||
NOTICE: drop cascades to 6 other objects
|
||||
NOTICE: drop cascades to 7 other objects
|
||||
|
Reference in New Issue
Block a user