Re: Transform for pl/perl

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Transform for pl/perl
Date: 2018-04-09 13:00:55
Message-ID: d8jtvskjzzs.fsf@dalvik.ping.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:

> On 3/15/18 03:46, Pavel Stehule wrote:
>> It looks well
>>
>> the patch has tests and doc,
>> there are not any warnings or compilation issues
>> all tests passed
>>
>> I'll mark this patch as ready for commiter
>
> committed

I played around with this a bit, and noticed that the number handling
doesn't cope with Perl UVs (unsigned integers) in the (IV_MAX, UV_MAX]
range:

ilmari(at)[local]:5432 ~=# CREATE FUNCTION testUVToJsonb() RETURNS jsonb
ilmari(at)[local]:5432 ~-# LANGUAGE plperl TRANSFORM FOR TYPE jsonb
ilmari(at)[local]:5432 ~-# as $$
ilmari(at)[local]:5432 ~$# $val = ~0;
ilmari(at)[local]:5432 ~$# elog(NOTICE, "value is $val");
ilmari(at)[local]:5432 ~$# return $val;
ilmari(at)[local]:5432 ~$# $$;
CREATE FUNCTION
Time: 6.795 ms
ilmari(at)[local]:5432 ~=# select testUVToJsonb();
NOTICE: value is 18446744073709551615
┌───────────────┐
│ testuvtojsonb │
├───────────────┤
│ -1 │
└───────────────┘
(1 row)

I tried fixing this by adding an 'if (SvUV(in))' clause to
SV_to_JsonbValue, but I couldn't find a function to create a numeric
value from an uint64. If it's not possible, should we error on UVs
greater than PG_INT64_MAX?

- ilmari
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2018-04-09 13:33:18 Re: PostgreSQL's handling of fsync() errors is unsafe and risks data loss at least on XFS
Previous Message Anthony Iliopoulos 2018-04-09 12:54:16 Re: PostgreSQL's handling of fsync() errors is unsafe and risks data loss at least on XFS