Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd780d7c

Browse files
committed
Change data type of counters in BufferUsage and WalUsage from long to int64.
Previously long was used as the data type for some counters in BufferUsageand WalUsage. But long is only four byte, e.g., on Windows, and it's entirelypossible to wrap a four byte counter. For example, emitting more thanfour billion WAL records in one transaction isn't actually particularly rare.To avoid the overflows of those counters, this commit changes the data typeof them from long to int64.Suggested-by: Andres FreundAuthor: Masahiro IkedaReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/20201221211650.k7b53tcnadrciqjo@alap3.anarazel.deDiscussion:https://postgr.es/m/af0964ac-7080-1984-dc23-513754987716@oss.nttdata.com
1 parent0bf6293 commitd780d7c

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,9 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
830830
}
831831
appendStringInfo(&buf,_("system usage: %s\n"),pg_rusage_show(&ru0));
832832
appendStringInfo(&buf,
833-
_("WAL usage: %ld records, %ld full page images, %llu bytes"),
834-
walusage.wal_records,
835-
walusage.wal_fpi,
833+
_("WAL usage: %lld records, %lld full page images, %llu bytes"),
834+
(long long)walusage.wal_records,
835+
(long long)walusage.wal_fpi,
836836
(unsigned long long)walusage.wal_bytes);
837837

838838
ereport(LOG,

‎src/backend/commands/explain.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,47 +3526,47 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage, bool planning)
35263526
{
35273527
appendStringInfoString(es->str," shared");
35283528
if (usage->shared_blks_hit>0)
3529-
appendStringInfo(es->str," hit=%ld",
3530-
usage->shared_blks_hit);
3529+
appendStringInfo(es->str," hit=%lld",
3530+
(long long)usage->shared_blks_hit);
35313531
if (usage->shared_blks_read>0)
3532-
appendStringInfo(es->str," read=%ld",
3533-
usage->shared_blks_read);
3532+
appendStringInfo(es->str," read=%lld",
3533+
(long long)usage->shared_blks_read);
35343534
if (usage->shared_blks_dirtied>0)
3535-
appendStringInfo(es->str," dirtied=%ld",
3536-
usage->shared_blks_dirtied);
3535+
appendStringInfo(es->str," dirtied=%lld",
3536+
(long long)usage->shared_blks_dirtied);
35373537
if (usage->shared_blks_written>0)
3538-
appendStringInfo(es->str," written=%ld",
3539-
usage->shared_blks_written);
3538+
appendStringInfo(es->str," written=%lld",
3539+
(long long)usage->shared_blks_written);
35403540
if (has_local||has_temp)
35413541
appendStringInfoChar(es->str,',');
35423542
}
35433543
if (has_local)
35443544
{
35453545
appendStringInfoString(es->str," local");
35463546
if (usage->local_blks_hit>0)
3547-
appendStringInfo(es->str," hit=%ld",
3548-
usage->local_blks_hit);
3547+
appendStringInfo(es->str," hit=%lld",
3548+
(long long)usage->local_blks_hit);
35493549
if (usage->local_blks_read>0)
3550-
appendStringInfo(es->str," read=%ld",
3551-
usage->local_blks_read);
3550+
appendStringInfo(es->str," read=%lld",
3551+
(long long)usage->local_blks_read);
35523552
if (usage->local_blks_dirtied>0)
3553-
appendStringInfo(es->str," dirtied=%ld",
3554-
usage->local_blks_dirtied);
3553+
appendStringInfo(es->str," dirtied=%lld",
3554+
(long long)usage->local_blks_dirtied);
35553555
if (usage->local_blks_written>0)
3556-
appendStringInfo(es->str," written=%ld",
3557-
usage->local_blks_written);
3556+
appendStringInfo(es->str," written=%lld",
3557+
(long long)usage->local_blks_written);
35583558
if (has_temp)
35593559
appendStringInfoChar(es->str,',');
35603560
}
35613561
if (has_temp)
35623562
{
35633563
appendStringInfoString(es->str," temp");
35643564
if (usage->temp_blks_read>0)
3565-
appendStringInfo(es->str," read=%ld",
3566-
usage->temp_blks_read);
3565+
appendStringInfo(es->str," read=%lld",
3566+
(long long)usage->temp_blks_read);
35673567
if (usage->temp_blks_written>0)
3568-
appendStringInfo(es->str," written=%ld",
3569-
usage->temp_blks_written);
3568+
appendStringInfo(es->str," written=%lld",
3569+
(long long)usage->temp_blks_written);
35703570
}
35713571
appendStringInfoChar(es->str,'\n');
35723572
}
@@ -3638,11 +3638,11 @@ show_wal_usage(ExplainState *es, const WalUsage *usage)
36383638
appendStringInfoString(es->str,"WAL:");
36393639

36403640
if (usage->wal_records>0)
3641-
appendStringInfo(es->str," records=%ld",
3642-
usage->wal_records);
3641+
appendStringInfo(es->str," records=%lld",
3642+
(long long)usage->wal_records);
36433643
if (usage->wal_fpi>0)
3644-
appendStringInfo(es->str," fpi=%ld",
3645-
usage->wal_fpi);
3644+
appendStringInfo(es->str," fpi=%lld",
3645+
(long long)usage->wal_fpi);
36463646
if (usage->wal_bytes>0)
36473647
appendStringInfo(es->str," bytes="UINT64_FORMAT,
36483648
usage->wal_bytes);

‎src/include/executor/instrument.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818

1919
typedefstructBufferUsage
2020
{
21-
longshared_blks_hit;/* # of shared buffer hits */
22-
longshared_blks_read;/* # of shared disk blocks read */
23-
longshared_blks_dirtied;/* # of shared blocks dirtied */
24-
longshared_blks_written;/* # of shared disk blocks written */
25-
longlocal_blks_hit;/* # of local buffer hits */
26-
longlocal_blks_read;/* # of local disk blocks read */
27-
longlocal_blks_dirtied;/* # of local blocks dirtied */
28-
longlocal_blks_written;/* # of local disk blocks written */
29-
longtemp_blks_read;/* # of temp blocks read */
30-
longtemp_blks_written;/* # of temp blocks written */
21+
int64shared_blks_hit;/* # of shared buffer hits */
22+
int64shared_blks_read;/* # of shared disk blocks read */
23+
int64shared_blks_dirtied;/* # of shared blocks dirtied */
24+
int64shared_blks_written;/* # of shared disk blocks written */
25+
int64local_blks_hit;/* # of local buffer hits */
26+
int64local_blks_read;/* # of local disk blocks read */
27+
int64local_blks_dirtied;/* # of local blocks dirtied */
28+
int64local_blks_written;/* # of local disk blocks written */
29+
int64temp_blks_read;/* # of temp blocks read */
30+
int64temp_blks_written;/* # of temp blocks written */
3131
instr_timeblk_read_time;/* time spent reading */
3232
instr_timeblk_write_time;/* time spent writing */
3333
}BufferUsage;
3434

3535
typedefstructWalUsage
3636
{
37-
longwal_records;/* # of WAL records produced */
38-
longwal_fpi;/* # of WAL full page images produced */
37+
int64wal_records;/* # of WAL records produced */
38+
int64wal_fpi;/* # of WAL full page images produced */
3939
uint64wal_bytes;/* size of WAL records produced */
4040
}WalUsage;
4141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp