Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdcJe-0003sM-Vu for pgsql-general@arkaria.postgresql.org; Fri, 13 Nov 2020 16:52:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdcJd-0005xV-V3 for pgsql-general@arkaria.postgresql.org; Fri, 13 Nov 2020 16:52:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdcJd-0005xM-N4 for pgsql-general@lists.postgresql.org; Fri, 13 Nov 2020 16:52:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdcJW-0006gn-Jm for pgsql-general@postgresql.org; Fri, 13 Nov 2020 16:52:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0ADGqc2q290288; Fri, 13 Nov 2020 11:52:39 -0500 From: Tom Lane To: Jan Behrens cc: pgsql-general@postgresql.org Subject: Re: Problem with psprintf and intmax_t (%jd) In-reply-to: <20201113172206.329d13b3f2189547449a7024@magnetkern.de> References: <20201113172206.329d13b3f2189547449a7024@magnetkern.de> Comments: In-reply-to Jan Behrens message dated "Fri, 13 Nov 2020 17:22:06 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <290286.1605286358.1@sss.pgh.pa.us> Date: Fri, 13 Nov 2020 11:52:38 -0500 Message-ID: <290287.1605286358@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jan Behrens writes: > I'm facing a problem with psprintf and the %jd format string. I used > the following C-code: > PG_RETURN_CSTRING(psprintf("%d@%jd", (int)1, (intmax_t)2)); > While this worked fine in past, I recently get (with PostgreSQL 13): > ERROR: vsnprintf failed: Invalid argument with format string "%d@%jd" Before PG 12, this would have worked (on many platforms) if your local libc's printf understood the "j" modifier. Since v12, we use src/port/snprintf.c on every platform, and it doesn't know "j". By and large, we do not use the types in Postgres, and are unlikely to start doing so. So this omission doesn't particularly concern me. "ll" with a cast to "long long" is indeed the recommended practice if you want to print a 64-bit value. regards, tom lane