Re: Cast jsonb to numeric, int, float, bool

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>, David Steele <david(at)pgmasters(dot)net>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Darafei Praliaskouski <me(at)komzpa(dot)net>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cast jsonb to numeric, int, float, bool
Date: 2018-05-08 15:51:59
Message-ID: dda6f9a9-4290-a85b-7d4d-e4b9968bac7e@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> 1) Does this really pass muster from the translatability standpoint?
>> I doubt it.
Huh, I missed that.

> I think you want the callers to look like
>
> if (!JsonbExtractScalar(&in->root, &v) || v.type != jbvNumeric)
> cannotCastJsonbValue(v.type, "double precision");
>
> where the subroutine contains the whole ereport() call, and its lookup
> table entries are e.g.
>
> gettext_noop("cannot cast jsonb string to type %s")
Thanks for your idea, patch is attached
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Attachment Content-Type Size
jsonb_cast_err_msg-v2.patch text/x-patch 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2018-05-08 16:13:18 Re: SQL:2011 Valid-Time Support
Previous Message Vladimir Sitnikov 2018-05-08 15:49:54 Re: [HACKERS] Clock with Adaptive Replacement