Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 201aa35

Browse files
committed
gcc did not like new pg_stat macros, for good and sufficient reason.
Add 'do { ... } while (0)' decoration to eliminate compiler warnings.
1 parent b6f75fe commit 201aa35

File tree

1 file changed

+65
-43
lines changed

1 file changed

+65
-43
lines changed

src/include/pgstat.h

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 2001, PostgreSQL Global Development Group
77
*
8-
* $Id: pgstat.h,v 1.2 2001/06/29 16:29:37 wieck Exp $
8+
* $Id: pgstat.h,v 1.3 2001/06/29 23:03:02 tgl Exp $
99
* ----------
1010
*/
1111
#ifndef PGSTAT_H
@@ -349,61 +349,83 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel);
349349

350350

351351
#define pgstat_reset_heap_scan(s) \
352-
if ((s)->tabentry != NULL) \
353-
(s)->heap_scan_counted = FALSE
352+
do { \
353+
if ((s)->tabentry != NULL) \
354+
(s)->heap_scan_counted = FALSE; \
355+
} while (0)
354356
#define pgstat_count_heap_scan(s) \
355-
if ((s)->tabentry != NULL && !(s)->heap_scan_counted) { \
356-
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
357-
(s)->heap_scan_counted = TRUE; \
358-
}
357+
do { \
358+
if ((s)->tabentry != NULL && !(s)->heap_scan_counted) { \
359+
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
360+
(s)->heap_scan_counted = TRUE; \
361+
} \
362+
} while (0)
359363
#define pgstat_count_heap_getnext(s) \
360-
if ((s)->tabentry != NULL) \
361-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++
364+
do { \
365+
if ((s)->tabentry != NULL) \
366+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++; \
367+
} while (0)
362368
#define pgstat_count_heap_fetch(s) \
363-
if ((s)->tabentry != NULL) \
364-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++
369+
do { \
370+
if ((s)->tabentry != NULL) \
371+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++; \
372+
} while (0)
365373
#define pgstat_count_heap_insert(s) \
366-
if ((s)->tabentry != NULL) \
367-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_inserted++
374+
do { \
375+
if ((s)->tabentry != NULL) \
376+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_inserted++; \
377+
} while (0)
368378
#define pgstat_count_heap_update(s) \
369-
if ((s)->tabentry != NULL) \
370-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++
379+
do { \
380+
if ((s)->tabentry != NULL) \
381+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++; \
382+
} while (0)
371383
#define pgstat_count_heap_delete(s) \
372-
if ((s)->tabentry != NULL) \
373-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++
374-
384+
do { \
385+
if ((s)->tabentry != NULL) \
386+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++; \
387+
} while (0)
375388
#define pgstat_reset_index_scan(s) \
376-
if ((s)->tabentry != NULL) \
377-
(s)->index_scan_counted = FALSE
389+
do { \
390+
if ((s)->tabentry != NULL) \
391+
(s)->index_scan_counted = FALSE; \
392+
} while (0)
378393
#define pgstat_count_index_scan(s) \
379-
if ((s)->tabentry != NULL && !(s)->index_scan_counted) { \
380-
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
381-
(s)->index_scan_counted = TRUE; \
382-
}
394+
do { \
395+
if ((s)->tabentry != NULL && !(s)->index_scan_counted) { \
396+
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
397+
(s)->index_scan_counted = TRUE; \
398+
} \
399+
} while (0)
383400
#define pgstat_count_index_getnext(s) \
384-
if ((s)->tabentry != NULL) \
385-
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++
386-
401+
do { \
402+
if ((s)->tabentry != NULL) \
403+
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++; \
404+
} while (0)
387405
#define pgstat_count_buffer_read(s,r) \
388-
if ((s)->tabentry != NULL) \
389-
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
390-
else { \
391-
if (!(s)->no_stats) { \
392-
pgstat_initstats((s), (r)); \
393-
if ((s)->tabentry != NULL) \
394-
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
406+
do { \
407+
if ((s)->tabentry != NULL) \
408+
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
409+
else { \
410+
if (!(s)->no_stats) { \
411+
pgstat_initstats((s), (r)); \
412+
if ((s)->tabentry != NULL) \
413+
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
414+
} \
395415
} \
396-
}
416+
} while (0)
397417
#define pgstat_count_buffer_hit(s,r) \
398-
if ((s)->tabentry != NULL) \
399-
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
400-
else { \
401-
if (!(s)->no_stats) { \
402-
pgstat_initstats((s), (r)); \
403-
if ((s)->tabentry != NULL) \
404-
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
418+
do { \
419+
if ((s)->tabentry != NULL) \
420+
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
421+
else { \
422+
if (!(s)->no_stats) { \
423+
pgstat_initstats((s), (r)); \
424+
if ((s)->tabentry != NULL) \
425+
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
426+
} \
405427
} \
406-
}
428+
} while (0)
407429

408430

409431
extern void pgstat_count_xact_commit(void);

0 commit comments

Comments
 (0)