pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jan Behrens <jbe-mlist@magnetkern.de>
Cc: pgsql-general@postgresql.org
Subject: Re: Problem with psprintf and intmax_t (%jd)
Date: Fri, 13 Nov 2020 11:52:38 -0500
Message-ID: <290287.1605286358@sss.pgh.pa.us> (raw)
In-Reply-To: <20201113172206.329d13b3f2189547449a7024@magnetkern.de>
References: <20201113172206.329d13b3f2189547449a7024@magnetkern.de>

Jan Behrens <jbe-mlist@magnetkern.de> 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 <stdint.h> 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





view thread (2+ messages)

Message-ID: <290287.1605286358@sss.pgh.pa.us>
Permalink:  ../290287.1605286358@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/290287.1605286358@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jbe-mlist@magnetkern.de
  Subject: Re: Problem with psprintf and intmax_t (%jd)
  In-Reply-To: <290287.1605286358@sss.pgh.pa.us>
  References: <20201113172206.329d13b3f2189547449a7024@magnetkern.de> <290287.1605286358@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox