@@ -1551,20 +1551,18 @@ pgstat_assert_is_up(void)
15511551 * ------------------------------------------------------------
15521552 */
15531553
1554- /*helpers for pgstat_write_statsfile() */
1555- static void
1556- write_chunk (FILE * fpout ,void * ptr ,size_t len )
1554+ /*helper for pgstat_write_statsfile() */
1555+ void
1556+ pgstat_write_chunk (FILE * fpout ,void * ptr ,size_t len )
15571557{
15581558int rc ;
15591559
15601560rc = fwrite (ptr ,len ,1 ,fpout );
15611561
1562- /*we'll check for errors with ferror once at theend */
1562+ /*We check for errors with ferror() when done writing thestats. */
15631563(void )rc ;
15641564}
15651565
1566- #define write_chunk_s (fpout ,ptr ) write_chunk(fpout, ptr, sizeof(*ptr))
1567-
15681566/*
15691567 * This function is called in the last process that is accessing the shared
15701568 * stats so locking is not required.
@@ -1606,7 +1604,7 @@ pgstat_write_statsfile(void)
16061604 * Write the file header --- currently just a format ID.
16071605 */
16081606format_id = PGSTAT_FILE_FORMAT_ID ;
1609- write_chunk_s (fpout ,& format_id );
1607+ pgstat_write_chunk_s (fpout ,& format_id );
16101608
16111609/* Write various stats structs for fixed number of objects */
16121610for (PgStat_Kind kind = PGSTAT_KIND_MIN ;kind <=PGSTAT_KIND_MAX ;kind ++ )
@@ -1631,8 +1629,8 @@ pgstat_write_statsfile(void)
16311629ptr = pgStatLocal .snapshot .custom_data [kind - PGSTAT_KIND_CUSTOM_MIN ];
16321630
16331631fputc (PGSTAT_FILE_ENTRY_FIXED ,fpout );
1634- write_chunk_s (fpout ,& kind );
1635- write_chunk (fpout ,ptr ,info -> shared_data_len );
1632+ pgstat_write_chunk_s (fpout ,& kind );
1633+ pgstat_write_chunk (fpout ,ptr ,info -> shared_data_len );
16361634}
16371635
16381636/*
@@ -1686,7 +1684,7 @@ pgstat_write_statsfile(void)
16861684{
16871685/* normal stats entry, identified by PgStat_HashKey */
16881686fputc (PGSTAT_FILE_ENTRY_HASH ,fpout );
1689- write_chunk_s (fpout ,& ps -> key );
1687+ pgstat_write_chunk_s (fpout ,& ps -> key );
16901688}
16911689else
16921690{
@@ -1696,21 +1694,21 @@ pgstat_write_statsfile(void)
16961694kind_info -> to_serialized_name (& ps -> key ,shstats ,& name );
16971695
16981696fputc (PGSTAT_FILE_ENTRY_NAME ,fpout );
1699- write_chunk_s (fpout ,& ps -> key .kind );
1700- write_chunk_s (fpout ,& name );
1697+ pgstat_write_chunk_s (fpout ,& ps -> key .kind );
1698+ pgstat_write_chunk_s (fpout ,& name );
17011699}
17021700
17031701/* Write except the header part of the entry */
1704- write_chunk (fpout ,
1705- pgstat_get_entry_data (ps -> key .kind ,shstats ),
1706- pgstat_get_entry_len (ps -> key .kind ));
1702+ pgstat_write_chunk (fpout ,
1703+ pgstat_get_entry_data (ps -> key .kind ,shstats ),
1704+ pgstat_get_entry_len (ps -> key .kind ));
17071705}
17081706dshash_seq_term (& hstat );
17091707
17101708/*
17111709 * No more output to be done. Close the temp file and replace the old
17121710 * pgstat.stat with it. The ferror() check replaces testing for error
1713- * after each individual fputc or fwrite (inwrite_chunk ()) above.
1711+ * after each individual fputc or fwrite (inpgstat_write_chunk ()) above.
17141712 */
17151713fputc (PGSTAT_FILE_ENTRY_END ,fpout );
17161714
@@ -1738,15 +1736,13 @@ pgstat_write_statsfile(void)
17381736}
17391737}
17401738
1741- /*helpers for pgstat_read_statsfile() */
1742- static bool
1743- read_chunk (FILE * fpin ,void * ptr ,size_t len )
1739+ /*helper for pgstat_read_statsfile() */
1740+ bool
1741+ pgstat_read_chunk (FILE * fpin ,void * ptr ,size_t len )
17441742{
17451743return fread (ptr ,1 ,len ,fpin )== len ;
17461744}
17471745
1748- #define read_chunk_s (fpin ,ptr ) read_chunk(fpin, ptr, sizeof(*ptr))
1749-
17501746/*
17511747 * Reads in existing statistics file into memory.
17521748 *
@@ -1790,7 +1786,7 @@ pgstat_read_statsfile(void)
17901786/*
17911787 * Verify it's of the expected format.
17921788 */
1793- if (!read_chunk_s (fpin ,& format_id ))
1789+ if (!pgstat_read_chunk_s (fpin ,& format_id ))
17941790{
17951791elog (WARNING ,"could not read format ID" );
17961792gotoerror ;
@@ -1820,7 +1816,7 @@ pgstat_read_statsfile(void)
18201816char * ptr ;
18211817
18221818/* entry for fixed-numbered stats */
1823- if (!read_chunk_s (fpin ,& kind ))
1819+ if (!pgstat_read_chunk_s (fpin ,& kind ))
18241820{
18251821elog (WARNING ,"could not read stats kind for entry of type %c" ,t );
18261822gotoerror ;
@@ -1860,7 +1856,7 @@ pgstat_read_statsfile(void)
18601856info -> shared_data_off ;
18611857}
18621858
1863- if (!read_chunk (fpin ,ptr ,info -> shared_data_len ))
1859+ if (!pgstat_read_chunk (fpin ,ptr ,info -> shared_data_len ))
18641860{
18651861elog (WARNING ,"could not read data of stats kind %u for entry of type %c with size %u" ,
18661862kind ,t ,info -> shared_data_len );
@@ -1881,7 +1877,7 @@ pgstat_read_statsfile(void)
18811877if (t == PGSTAT_FILE_ENTRY_HASH )
18821878{
18831879/* normal stats entry, identified by PgStat_HashKey */
1884- if (!read_chunk_s (fpin ,& key ))
1880+ if (!pgstat_read_chunk_s (fpin ,& key ))
18851881{
18861882elog (WARNING ,"could not read key for entry of type %c" ,t );
18871883gotoerror ;
@@ -1910,12 +1906,12 @@ pgstat_read_statsfile(void)
19101906PgStat_Kind kind ;
19111907NameData name ;
19121908
1913- if (!read_chunk_s (fpin ,& kind ))
1909+ if (!pgstat_read_chunk_s (fpin ,& kind ))
19141910{
19151911elog (WARNING ,"could not read stats kind for entry of type %c" ,t );
19161912gotoerror ;
19171913}
1918- if (!read_chunk_s (fpin ,& name ))
1914+ if (!pgstat_read_chunk_s (fpin ,& name ))
19191915{
19201916elog (WARNING ,"could not read name of stats kind %u for entry of type %c" ,
19211917kind ,t );
@@ -1990,9 +1986,9 @@ pgstat_read_statsfile(void)
19901986key .objid ,t );
19911987}
19921988
1993- if (!read_chunk (fpin ,
1994- pgstat_get_entry_data (key .kind ,header ),
1995- pgstat_get_entry_len (key .kind )))
1989+ if (!pgstat_read_chunk (fpin ,
1990+ pgstat_get_entry_data (key .kind ,header ),
1991+ pgstat_get_entry_len (key .kind )))
19961992{
19971993elog (WARNING ,"could not read data for entry %u/%u/%" PRIu64 " of type %c" ,
19981994key .kind ,key .dboid ,