On Fri, Nov 27, 2020 at 04:10:27PM +0530, Ashutosh Bapat wrote: > LSN_FORMAT_ARG expands to two comma separated arguments and is kinda > open at both ends but it's handy that way.
Agreed that's useful. > Off list Peter Eisentraut pointed out that we can not use these macros > in elog/ereport since it creates problems for translations. He > suggested adding functions which return strings and use %s when doing > so. What's the problem with translations? We already have equivalent stuff with INT64_FORMAT that may map to %ld or %lld. But here we have a format that's set in stone. > The patch has two functions pg_lsn_out_internal() which takes an LSN > as input and returns a palloc'ed string containing the string > representation of LSN. This may not be suitable in performance > critical paths and also may leak memory if not freed. I'd rather never use this flavor. An OOM could mask the actual error behind. > Off list Craig Ringer suggested introducing a new format specifier > similar to %m for LSN but I did not get time to take a look at the > relevant code. AFAIU it's available only to elog/ereport, so may not > be useful generally. But teaching printf variants about the new format > would be the best solution. However, I didn't find any way to do that. -1. %m maps to errno, that is much more generic. A set of macros that maps to our internal format would be fine enough IMO. -- Michael
signature.asc
Description: PGP signature