mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Standardize LSN formatting by zero padding
This commit standardizes the output format for LSNs to ensure consistent representation across various tools and messages. Previously, LSNs were inconsistently printed as `%X/%X` in some contexts, while others used zero-padding. This often led to confusion when comparing. To address this, the LSN format is now uniformly set to `%X/%08X`, ensuring the lower 32-bit part is always zero-padded to eight hexadecimal digits. Author: Japin Li <japinli@hotmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/ME0P300MB0445CA53CA0E4B8C1879AF84B641A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
This commit is contained in:
@ -5,21 +5,21 @@ CREATE UNLOGGED TABLE test_gist AS SELECT point(i,i) p, i::text t FROM
|
||||
CREATE INDEX test_gist_idx ON test_gist USING gist (p);
|
||||
-- Page 0 is the root, the rest are leaf pages
|
||||
SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 0));
|
||||
lsn | nsn | rightlink | flags
|
||||
-----+-----+------------+-------
|
||||
0/1 | 0/0 | 4294967295 | {}
|
||||
lsn | nsn | rightlink | flags
|
||||
------------+------------+------------+-------
|
||||
0/00000001 | 0/00000000 | 4294967295 | {}
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 1));
|
||||
lsn | nsn | rightlink | flags
|
||||
-----+-----+------------+--------
|
||||
0/1 | 0/0 | 4294967295 | {leaf}
|
||||
lsn | nsn | rightlink | flags
|
||||
------------+------------+------------+--------
|
||||
0/00000001 | 0/00000000 | 4294967295 | {leaf}
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2));
|
||||
lsn | nsn | rightlink | flags
|
||||
-----+-----+-----------+--------
|
||||
0/1 | 0/0 | 1 | {leaf}
|
||||
lsn | nsn | rightlink | flags
|
||||
------------+------------+-----------+--------
|
||||
0/00000001 | 0/00000000 | 1 | {leaf}
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx');
|
||||
|
@ -265,9 +265,9 @@ SELECT fsm_page_contents(decode(repeat('00', :block_size), 'hex'));
|
||||
(1 row)
|
||||
|
||||
SELECT page_header(decode(repeat('00', :block_size), 'hex'));
|
||||
page_header
|
||||
-----------------------
|
||||
(0/0,0,0,0,0,0,0,0,0)
|
||||
page_header
|
||||
------------------------------
|
||||
(0/00000000,0,0,0,0,0,0,0,0)
|
||||
(1 row)
|
||||
|
||||
SELECT page_checksum(decode(repeat('00', :block_size), 'hex'), 1);
|
||||
|
@ -282,7 +282,7 @@ page_header(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char lsnchar[64];
|
||||
|
||||
snprintf(lsnchar, sizeof(lsnchar), "%X/%X", LSN_FORMAT_ARGS(lsn));
|
||||
snprintf(lsnchar, sizeof(lsnchar), "%X/%08X", LSN_FORMAT_ARGS(lsn));
|
||||
values[0] = CStringGetTextDatum(lsnchar);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user