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

Commit f3e4b95

Browse files
committed
Make ExplainPropertyInteger accept 64bit input, remove *Long variant.
'long' is not useful type across platforms, as it's 32bit on 32 bit platforms, and even on some 64bit platforms (e.g. windows) it's still only 32bits wide. As ExplainPropertyInteger should never be performance critical, change it to accept a 64bit argument and remove ExplainPropertyLong. Author: Andres Freund Discussion: https://postgr.es/m/20180314164832.n56wt7zcbpzi6zxe@alap3.anarazel.de
1 parent 9e17bdb commit f3e4b95

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

contrib/file_fdw/file_fdw.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ fileExplainForeignScan(ForeignScanState *node, ExplainState *es)
622622

623623
if (!is_program &&
624624
stat(filename, &stat_buf) == 0)
625-
ExplainPropertyLong("Foreign File Size", (long) stat_buf.st_size,
626-
es);
625+
ExplainPropertyInteger("Foreign File Size",
626+
(int64) stat_buf.st_size, es);
627627
}
628628
}
629629

src/backend/commands/explain.c

+36-35
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
14001400
show_instrumentation_count("Rows Removed by Filter", 1,
14011401
planstate, es);
14021402
if (es->analyze)
1403-
ExplainPropertyLong("Heap Fetches",
1404-
((IndexOnlyScanState *) planstate)->ioss_HeapFetches, es);
1403+
ExplainPropertyInteger("Heap Fetches",
1404+
((IndexOnlyScanState *) planstate)->ioss_HeapFetches,
1405+
es);
14051406
break;
14061407
case T_BitmapIndexScan:
14071408
show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig,
@@ -2325,7 +2326,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
23252326
else
23262327
{
23272328
ExplainPropertyText("Sort Method", sortMethod, es);
2328-
ExplainPropertyLong("Sort Space Used", spaceUsed, es);
2329+
ExplainPropertyInteger("Sort Space Used", spaceUsed, es);
23292330
ExplainPropertyText("Sort Space Type", spaceType, es);
23302331
}
23312332
}
@@ -2366,7 +2367,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
23662367
ExplainOpenGroup("Worker", NULL, true, es);
23672368
ExplainPropertyInteger("Worker Number", n, es);
23682369
ExplainPropertyText("Sort Method", sortMethod, es);
2369-
ExplainPropertyLong("Sort Space Used", spaceUsed, es);
2370+
ExplainPropertyInteger("Sort Space Used", spaceUsed, es);
23702371
ExplainPropertyText("Sort Space Type", spaceType, es);
23712372
ExplainCloseGroup("Worker", NULL, true, es);
23722373
}
@@ -2445,13 +2446,13 @@ show_hash_info(HashState *hashstate, ExplainState *es)
24452446

24462447
if (es->format != EXPLAIN_FORMAT_TEXT)
24472448
{
2448-
ExplainPropertyLong("Hash Buckets", hinstrument.nbuckets, es);
2449-
ExplainPropertyLong("Original Hash Buckets",
2449+
ExplainPropertyInteger("Hash Buckets", hinstrument.nbuckets, es);
2450+
ExplainPropertyInteger("Original Hash Buckets",
24502451
hinstrument.nbuckets_original, es);
2451-
ExplainPropertyLong("Hash Batches", hinstrument.nbatch, es);
2452-
ExplainPropertyLong("Original Hash Batches",
2452+
ExplainPropertyInteger("Hash Batches", hinstrument.nbatch, es);
2453+
ExplainPropertyInteger("Original Hash Batches",
24532454
hinstrument.nbatch_original, es);
2454-
ExplainPropertyLong("Peak Memory Usage", spacePeakKb, es);
2455+
ExplainPropertyInteger("Peak Memory Usage", spacePeakKb, es);
24552456
}
24562457
else if (hinstrument.nbatch_original != hinstrument.nbatch ||
24572458
hinstrument.nbuckets_original != hinstrument.nbuckets)
@@ -2484,8 +2485,10 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
24842485
{
24852486
if (es->format != EXPLAIN_FORMAT_TEXT)
24862487
{
2487-
ExplainPropertyLong("Exact Heap Blocks", planstate->exact_pages, es);
2488-
ExplainPropertyLong("Lossy Heap Blocks", planstate->lossy_pages, es);
2488+
ExplainPropertyInteger("Exact Heap Blocks",
2489+
planstate->exact_pages, es);
2490+
ExplainPropertyInteger("Lossy Heap Blocks",
2491+
planstate->lossy_pages, es);
24892492
}
24902493
else
24912494
{
@@ -2695,16 +2698,26 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage)
26952698
}
26962699
else
26972700
{
2698-
ExplainPropertyLong("Shared Hit Blocks", usage->shared_blks_hit, es);
2699-
ExplainPropertyLong("Shared Read Blocks", usage->shared_blks_read, es);
2700-
ExplainPropertyLong("Shared Dirtied Blocks", usage->shared_blks_dirtied, es);
2701-
ExplainPropertyLong("Shared Written Blocks", usage->shared_blks_written, es);
2702-
ExplainPropertyLong("Local Hit Blocks", usage->local_blks_hit, es);
2703-
ExplainPropertyLong("Local Read Blocks", usage->local_blks_read, es);
2704-
ExplainPropertyLong("Local Dirtied Blocks", usage->local_blks_dirtied, es);
2705-
ExplainPropertyLong("Local Written Blocks", usage->local_blks_written, es);
2706-
ExplainPropertyLong("Temp Read Blocks", usage->temp_blks_read, es);
2707-
ExplainPropertyLong("Temp Written Blocks", usage->temp_blks_written, es);
2701+
ExplainPropertyInteger("Shared Hit Blocks",
2702+
usage->shared_blks_hit, es);
2703+
ExplainPropertyInteger("Shared Read Blocks",
2704+
usage->shared_blks_read, es);
2705+
ExplainPropertyInteger("Shared Dirtied Blocks",
2706+
usage->shared_blks_dirtied, es);
2707+
ExplainPropertyInteger("Shared Written Blocks",
2708+
usage->shared_blks_written, es);
2709+
ExplainPropertyInteger("Local Hit Blocks",
2710+
usage->local_blks_hit, es);
2711+
ExplainPropertyInteger("Local Read Blocks",
2712+
usage->local_blks_read, es);
2713+
ExplainPropertyInteger("Local Dirtied Blocks",
2714+
usage->local_blks_dirtied, es);
2715+
ExplainPropertyInteger("Local Written Blocks",
2716+
usage->local_blks_written, es);
2717+
ExplainPropertyInteger("Temp Read Blocks",
2718+
usage->temp_blks_read, es);
2719+
ExplainPropertyInteger("Temp Written Blocks",
2720+
usage->temp_blks_written, es);
27082721
if (track_io_timing)
27092722
{
27102723
ExplainPropertyFloat("I/O Read Time", INSTR_TIME_GET_MILLISEC(usage->blk_read_time), 3, es);
@@ -3309,23 +3322,11 @@ ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
33093322
* Explain an integer-valued property.
33103323
*/
33113324
void
3312-
ExplainPropertyInteger(const char *qlabel, int value, ExplainState *es)
3325+
ExplainPropertyInteger(const char *qlabel, int64 value, ExplainState *es)
33133326
{
33143327
char buf[32];
33153328

3316-
snprintf(buf, sizeof(buf), "%d", value);
3317-
ExplainProperty(qlabel, buf, true, es);
3318-
}
3319-
3320-
/*
3321-
* Explain a long-integer-valued property.
3322-
*/
3323-
void
3324-
ExplainPropertyLong(const char *qlabel, long value, ExplainState *es)
3325-
{
3326-
char buf[32];
3327-
3328-
snprintf(buf, sizeof(buf), "%ld", value);
3329+
snprintf(buf, sizeof(buf), INT64_FORMAT, value);
33293330
ExplainProperty(qlabel, buf, true, es);
33303331
}
33313332

src/include/commands/explain.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ extern void ExplainPropertyListNested(const char *qlabel, List *data,
9393
ExplainState *es);
9494
extern void ExplainPropertyText(const char *qlabel, const char *value,
9595
ExplainState *es);
96-
extern void ExplainPropertyInteger(const char *qlabel, int value,
96+
extern void ExplainPropertyInteger(const char *qlabel, int64 value,
9797
ExplainState *es);
98-
extern void ExplainPropertyLong(const char *qlabel, long value,
99-
ExplainState *es);
10098
extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
10199
ExplainState *es);
102100
extern void ExplainPropertyBool(const char *qlabel, bool value,

0 commit comments

Comments
 (0)