Re: Problem with psprintf and intmax_t (%jd)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Behrens <jbe-mlist(at)magnetkern(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with psprintf and intmax_t (%jd)
Date: 2020-11-13 16:52:38
Message-ID: 290287.1605286358@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jan Behrens <jbe-mlist(at)magnetkern(dot)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(at)%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(at)%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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dirk Mika 2020-11-13 16:56:50 PostgreSQL equivalent to Oracles ANYDATASET
Previous Message Jeremy Wilson 2020-11-13 16:40:56 Re: Issue upgrading from 9.5 to 13 with pg_upgrade: "connection to database failed: FATAL: database "template1" does not exist"