mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Simplify printing of LSNs
Add a macro LSN_FORMAT_ARGS for use in printf-style printing of LSNs. Convert all applicable code to use it. Reviewed-by: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/CAExHW5ub5NaTELZ3hJUCE6amuvqAtsSxc7O+uK7y4t9Rrk23cw@mail.gmail.com
This commit is contained in:
@@ -83,14 +83,8 @@ pg_lsn_out(PG_FUNCTION_ARGS)
|
||||
XLogRecPtr lsn = PG_GETARG_LSN(0);
|
||||
char buf[MAXPG_LSNLEN + 1];
|
||||
char *result;
|
||||
uint32 id,
|
||||
off;
|
||||
|
||||
/* Decode ID and offset */
|
||||
id = (uint32) (lsn >> 32);
|
||||
off = (uint32) lsn;
|
||||
|
||||
snprintf(buf, sizeof buf, "%X/%X", id, off);
|
||||
snprintf(buf, sizeof buf, "%X/%X", LSN_FORMAT_ARGS(lsn));
|
||||
result = pstrdup(buf);
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user