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 1fG3b3-0008C6-9d for pgsql-hackers@arkaria.postgresql.org; Tue, 08 May 2018 14:28:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fG3b2-0001cH-6d for pgsql-hackers@arkaria.postgresql.org; Tue, 08 May 2018 14:28:04 +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 1fG3b1-0001bq-W9 for pgsql-hackers@lists.postgresql.org; Tue, 08 May 2018 14:28:04 +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 1fG3aq-0004ES-RI for pgsql-hackers@lists.postgresql.org; Tue, 08 May 2018 14:28:03 +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 w48ERbIt024823; Tue, 8 May 2018 10:27:37 -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: 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> Comments: In-reply-to Teodor Sigaev message dated "Tue, 08 May 2018 16:56:31 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24821.1525789657.1@sss.pgh.pa.us> Date: Tue, 08 May 2018 10:27:37 -0400 Message-ID: <24822.1525789657@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Teodor Sigaev writes: > Does anybody have an objections to patch? 1) Does this really pass muster from the translatability standpoint? I doubt it. I'd expect the translation of "cannot cast jsonb string to int4" to use a translated equivalent of "string", but this code will not do that. You can't really fix it by gettext'ing the result of JsonbTypeName, either, because then you're breaking the rule about not assembling translated strings from components. 2) Our usual convention for type names that are written in error messages is to use the SQL-standard names, that is "integer" and "double precision" and so on. For instance, float8in and int4in do not use the internal type names in their messages: regression=# select 'bogus'::float8; ERROR: invalid input syntax for type double precision: "bogus" LINE 1: select 'bogus'::float8; ^ regression=# select 'bogus'::int4; ERROR: invalid input syntax for integer: "bogus" LINE 1: select 'bogus'::int4; ^ So I think you made the wrong choices in jsonb_int4 etc. regards, tom lane