Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fG4Mt-0003VE-1c for pgsql-hackers@arkaria.postgresql.org; Tue, 08 May 2018 15:17:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fG4Mq-0001fr-SD for pgsql-hackers@arkaria.postgresql.org; Tue, 08 May 2018 15:17:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fG4Mq-0001fg-LL for pgsql-hackers@lists.postgresql.org; Tue, 08 May 2018 15:17:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fG4Mn-0005X0-EM for pgsql-hackers@lists.postgresql.org; Tue, 08 May 2018 15:17:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w48FHDDQ002088; Tue, 8 May 2018 11:17:13 -0400 From: Tom Lane To: Teodor Sigaev cc: Robert Haas , =?UTF-8?Q?Dagfinn_Ilmari_Manns=c3=a5ker?= , Aleksander Alekseev , David Steele , Nikita Glukhov , Darafei Praliaskouski , Anastasia Lubennikova , PostgreSQL Hackers Subject: Re: Cast jsonb to numeric, int, float, bool In-reply-to: <24822.1525789657@sss.pgh.pa.us> References: <151985418868.6915.17223208131889314092.pgcf@coridan.postgresql.org> <76b000ae-94d1-cd8f-a2e0-e536096469b0@postgrespro.ru> <20180327145337.GA20311@e733.localdomain> <912e1a07-90a9-ad97-bc70-d71ec0f6f073@sigaev.ru> <0250b45d-4a38-5453-cb5a-8fa9883da36b@sigaev.ru> <20180330142119.GA1411@e733.localdomain> <20180330142423.GB1411@e733.localdomain> <24822.1525789657@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 08 May 2018 10:27:37 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2085.1525792633.1@sss.pgh.pa.us> Date: Tue, 08 May 2018 11:17:13 -0400 Message-ID: <2087.1525792633@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > 1) Does this really pass muster from the translatability standpoint? > I doubt it. After further thought about that, it seems that what we typically don't try to translate is SQL-standard type names, that is, error messages along the line of "blah blah blah type %s" are considered fine. So the problem here is that you factorized the error reporting poorly. 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") regards, tom lane