From: | Jan Behrens <jbe-mlist(at)magnetkern(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Problem with psprintf and intmax_t (%jd) |
Date: | 2020-11-13 16:22:06 |
Message-ID: | 20201113172206.329d13b3f2189547449a7024@magnetkern.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dear all,
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"
I was not able to figure out what's the problem. Apparently this error
is thrown when vsnprintf(buf, len, fmt, args) in src/common/psprintf.c
returns a negative value. However, calling snprintf(buf, len, "%d(at)%jd",
(int)1, (intmax_t)2)) in a separate test program works fine on my
system.
I found a workaround. The following call works fine:
PG_RETURN_CSTRING(psprintf("%d(at)%lld", (int)1, (long long)2));
I could live with the workaround, but it is a bit scary, as I don't
really understand why "%jd" fails while "%lld" does not. Does anyone
know why, and/or is it possible for anyone else to reproduce the
problem?
Kind regards,
Jan Behrens
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2020-11-13 16:26:17 | Re: Issue upgrading from 9.5 to 13 with pg_upgrade: "connection to database failed: FATAL: database "template1" does not exist" |
Previous Message | Jeremy Wilson | 2020-11-13 16:19:16 | Re: Issue upgrading from 9.5 to 13 with pg_upgrade: "connection to database failed: FATAL: database "template1" does not exist" |