Skip to content

Commit 57796a0

Browse files
committed
Use float8 datatype for percentiles in pg_walinspect stat functions
pg_walinspect uses datatype double (double precision floating point number) for WAL stats percentile calculations and expose them via float4 (single precision floating point number), which an unnecessary loss of precision and confusing. Even though, it's harmless that way, let's use float8 (double precision floating-point number) to be in sync with what pg_walinspect does internally and what it exposes to the users. This seems to be the pattern used elsewhere in the code. Reported-by: Peter Eisentraut Author: Bharath Rupireddy Reviewed-by: Peter Eisentraut Discussion: https://www.postgresql.org/message-id/36ee692b-232f-0484-ce94-dc39d82021ad%40enterprisedb.com
1 parent 88f4883 commit 57796a0

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

contrib/pg_walinspect/pg_walinspect--1.0.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ CREATE FUNCTION pg_get_wal_stats(IN start_lsn pg_lsn,
8080
IN per_record boolean DEFAULT false,
8181
OUT "resource_manager/record_type" text,
8282
OUT count int8,
83-
OUT count_percentage float4,
83+
OUT count_percentage float8,
8484
OUT record_size int8,
85-
OUT record_size_percentage float4,
85+
OUT record_size_percentage float8,
8686
OUT fpi_size int8,
87-
OUT fpi_size_percentage float4,
87+
OUT fpi_size_percentage float8,
8888
OUT combined_size int8,
89-
OUT combined_size_percentage float4
89+
OUT combined_size_percentage float8
9090
)
9191
RETURNS SETOF record
9292
AS 'MODULE_PATHNAME', 'pg_get_wal_stats'
@@ -102,13 +102,13 @@ CREATE FUNCTION pg_get_wal_stats_till_end_of_wal(IN start_lsn pg_lsn,
102102
IN per_record boolean DEFAULT false,
103103
OUT "resource_manager/record_type" text,
104104
OUT count int8,
105-
OUT count_percentage float4,
105+
OUT count_percentage float8,
106106
OUT record_size int8,
107-
OUT record_size_percentage float4,
107+
OUT record_size_percentage float8,
108108
OUT fpi_size int8,
109-
OUT fpi_size_percentage float4,
109+
OUT fpi_size_percentage float8,
110110
OUT combined_size int8,
111-
OUT combined_size_percentage float4
111+
OUT combined_size_percentage float8
112112
)
113113
RETURNS SETOF record
114114
AS 'MODULE_PATHNAME', 'pg_get_wal_stats_till_end_of_wal'

contrib/pg_walinspect/pg_walinspect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ FillXLogStatsRow(const char *name,
430430

431431
values[i++] = CStringGetTextDatum(name);
432432
values[i++] = Int64GetDatum(n);
433-
values[i++] = Float4GetDatum(n_pct);
433+
values[i++] = Float8GetDatum(n_pct);
434434
values[i++] = Int64GetDatum(rec_len);
435-
values[i++] = Float4GetDatum(rec_len_pct);
435+
values[i++] = Float8GetDatum(rec_len_pct);
436436
values[i++] = Int64GetDatum(fpi_len);
437-
values[i++] = Float4GetDatum(fpi_len_pct);
437+
values[i++] = Float8GetDatum(fpi_len_pct);
438438
values[i++] = Int64GetDatum(tot_len);
439-
values[i++] = Float4GetDatum(tot_len_pct);
439+
values[i++] = Float8GetDatum(tot_len_pct);
440440

441441
Assert(i == ncols);
442442
}

doc/src/sgml/pgwalinspect.sgml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ postgres=# select start_lsn, end_lsn, prev_lsn, xid, resource_manager, record_ty
164164
per_record boolean DEFAULT false,
165165
"resource_manager/record_type" OUT text,
166166
count OUT int8,
167-
count_percentage OUT float4,
167+
count_percentage OUT float8,
168168
record_length OUT int8,
169-
record_length_percentage OUT float4,
169+
record_length_percentage OUT float8,
170170
fpi_length OUT int8,
171-
fpi_length_percentage OUT float4,
171+
fpi_length_percentage OUT float8,
172172
combined_size OUT int8,
173-
combined_size_percentage OUT float4)
173+
combined_size_percentage OUT float8)
174174
returns setof record
175175
</function>
176176
</term>
@@ -241,13 +241,13 @@ postgres=# select * from pg_get_wal_stats('0/14AFC30', '0/15011D7', true) where
241241
per_record boolean DEFAULT false,
242242
"resource_manager/record_type" OUT text,
243243
count OUT int8,
244-
count_percentage OUT float4,
244+
count_percentage OUT float8,
245245
record_length OUT int8,
246-
record_length_percentage OUT float4,
246+
record_length_percentage OUT float8,
247247
fpi_length OUT int8,
248-
fpi_length_percentage OUT float4,
248+
fpi_length_percentage OUT float8,
249249
combined_size OUT int8,
250-
combined_size_percentage OUT float4)
250+
combined_size_percentage OUT float8)
251251
returns setof record
252252
</function>
253253
</term>

0 commit comments

Comments
 (0)