From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "ldh(at)laurent-hasson(dot)com" <ldh(at)laurent-hasson(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Big Performance drop of Exceptions in UDFs between V11.2 and 13.4 |
Date: | 2021-08-30 02:43:23 |
Message-ID: | CAFj8pRDPew1rg3c-WNxQmUugO0FQRyg3MTy67-qoUtGA=fwZ6Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi
po 30. 8. 2021 v 2:44 odesílatel ldh(at)laurent-hasson(dot)com <
ldh(at)laurent-hasson(dot)com> napsal:
>
>
>
> At this point, I am not sure how to proceed except to rethink that
> toFloat() function and many other places where we use exceptions. We get
> such dirty data that I need a "safe" way to convert a string to float
> without throwing an exception. BTW, I tried other combinations in case
> there may have been some weird interactions with the ::REAL conversion
> operator, but nothing made any change. Could you recommend another approach
> off the top of your head? I could use regexes for testing etc... Or maybe
> there is another option like a no-throw conversion that's built in or in
> some extension that you may know of? Like the "SAFE." Prefix in BigQuery.
>
CREATE OR REPLACE FUNCTION safe_to_double_precision(t text)
RETURNS double precision AS $$
BEGIN
IF $1 SIMILAR TO '[+-]?([0-9]*[.])?[0-9]+' THEN
RETURN $1::double precision;
ELSE
RETURN NULL;
END IF;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;
Regards
Pavel
>
> Thank you,
> Laurent.
>
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2021-08-30 03:16:48 | Re: Big Performance drop of Exceptions in UDFs between V11.2 and 13.4 (workarounds) |
Previous Message | Julien Rouhaud | 2021-08-30 02:23:08 | Re: Big Performance drop of Exceptions in UDFs between V11.2 and 13.4 |