Commit f3e4b95e authored by Andres Freund's avatar Andres Freund

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
parent 9e17bdb8
...@@ -622,8 +622,8 @@ fileExplainForeignScan(ForeignScanState *node, ExplainState *es) ...@@ -622,8 +622,8 @@ fileExplainForeignScan(ForeignScanState *node, ExplainState *es)
if (!is_program && if (!is_program &&
stat(filename, &stat_buf) == 0) stat(filename, &stat_buf) == 0)
ExplainPropertyLong("Foreign File Size", (long) stat_buf.st_size, ExplainPropertyInteger("Foreign File Size",
es); (int64) stat_buf.st_size, es);
} }
} }
......
...@@ -1400,8 +1400,9 @@ ExplainNode(PlanState *planstate, List *ancestors, ...@@ -1400,8 +1400,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
show_instrumentation_count("Rows Removed by Filter", 1, show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es); planstate, es);
if (es->analyze) if (es->analyze)
ExplainPropertyLong("Heap Fetches", ExplainPropertyInteger("Heap Fetches",
((IndexOnlyScanState *) planstate)->ioss_HeapFetches, es); ((IndexOnlyScanState *) planstate)->ioss_HeapFetches,
es);
break; break;
case T_BitmapIndexScan: case T_BitmapIndexScan:
show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig, show_scan_qual(((BitmapIndexScan *) plan)->indexqualorig,
...@@ -2325,7 +2326,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2325,7 +2326,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
else else
{ {
ExplainPropertyText("Sort Method", sortMethod, es); ExplainPropertyText("Sort Method", sortMethod, es);
ExplainPropertyLong("Sort Space Used", spaceUsed, es); ExplainPropertyInteger("Sort Space Used", spaceUsed, es);
ExplainPropertyText("Sort Space Type", spaceType, es); ExplainPropertyText("Sort Space Type", spaceType, es);
} }
} }
...@@ -2366,7 +2367,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2366,7 +2367,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
ExplainOpenGroup("Worker", NULL, true, es); ExplainOpenGroup("Worker", NULL, true, es);
ExplainPropertyInteger("Worker Number", n, es); ExplainPropertyInteger("Worker Number", n, es);
ExplainPropertyText("Sort Method", sortMethod, es); ExplainPropertyText("Sort Method", sortMethod, es);
ExplainPropertyLong("Sort Space Used", spaceUsed, es); ExplainPropertyInteger("Sort Space Used", spaceUsed, es);
ExplainPropertyText("Sort Space Type", spaceType, es); ExplainPropertyText("Sort Space Type", spaceType, es);
ExplainCloseGroup("Worker", NULL, true, es); ExplainCloseGroup("Worker", NULL, true, es);
} }
...@@ -2445,13 +2446,13 @@ show_hash_info(HashState *hashstate, ExplainState *es) ...@@ -2445,13 +2446,13 @@ show_hash_info(HashState *hashstate, ExplainState *es)
if (es->format != EXPLAIN_FORMAT_TEXT) if (es->format != EXPLAIN_FORMAT_TEXT)
{ {
ExplainPropertyLong("Hash Buckets", hinstrument.nbuckets, es); ExplainPropertyInteger("Hash Buckets", hinstrument.nbuckets, es);
ExplainPropertyLong("Original Hash Buckets", ExplainPropertyInteger("Original Hash Buckets",
hinstrument.nbuckets_original, es); hinstrument.nbuckets_original, es);
ExplainPropertyLong("Hash Batches", hinstrument.nbatch, es); ExplainPropertyInteger("Hash Batches", hinstrument.nbatch, es);
ExplainPropertyLong("Original Hash Batches", ExplainPropertyInteger("Original Hash Batches",
hinstrument.nbatch_original, es); hinstrument.nbatch_original, es);
ExplainPropertyLong("Peak Memory Usage", spacePeakKb, es); ExplainPropertyInteger("Peak Memory Usage", spacePeakKb, es);
} }
else if (hinstrument.nbatch_original != hinstrument.nbatch || else if (hinstrument.nbatch_original != hinstrument.nbatch ||
hinstrument.nbuckets_original != hinstrument.nbuckets) hinstrument.nbuckets_original != hinstrument.nbuckets)
...@@ -2484,8 +2485,10 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es) ...@@ -2484,8 +2485,10 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
{ {
if (es->format != EXPLAIN_FORMAT_TEXT) if (es->format != EXPLAIN_FORMAT_TEXT)
{ {
ExplainPropertyLong("Exact Heap Blocks", planstate->exact_pages, es); ExplainPropertyInteger("Exact Heap Blocks",
ExplainPropertyLong("Lossy Heap Blocks", planstate->lossy_pages, es); planstate->exact_pages, es);
ExplainPropertyInteger("Lossy Heap Blocks",
planstate->lossy_pages, es);
} }
else else
{ {
...@@ -2695,16 +2698,26 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage) ...@@ -2695,16 +2698,26 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage)
} }
else else
{ {
ExplainPropertyLong("Shared Hit Blocks", usage->shared_blks_hit, es); ExplainPropertyInteger("Shared Hit Blocks",
ExplainPropertyLong("Shared Read Blocks", usage->shared_blks_read, es); usage->shared_blks_hit, es);
ExplainPropertyLong("Shared Dirtied Blocks", usage->shared_blks_dirtied, es); ExplainPropertyInteger("Shared Read Blocks",
ExplainPropertyLong("Shared Written Blocks", usage->shared_blks_written, es); usage->shared_blks_read, es);
ExplainPropertyLong("Local Hit Blocks", usage->local_blks_hit, es); ExplainPropertyInteger("Shared Dirtied Blocks",
ExplainPropertyLong("Local Read Blocks", usage->local_blks_read, es); usage->shared_blks_dirtied, es);
ExplainPropertyLong("Local Dirtied Blocks", usage->local_blks_dirtied, es); ExplainPropertyInteger("Shared Written Blocks",
ExplainPropertyLong("Local Written Blocks", usage->local_blks_written, es); usage->shared_blks_written, es);
ExplainPropertyLong("Temp Read Blocks", usage->temp_blks_read, es); ExplainPropertyInteger("Local Hit Blocks",
ExplainPropertyLong("Temp Written Blocks", usage->temp_blks_written, es); usage->local_blks_hit, es);
ExplainPropertyInteger("Local Read Blocks",
usage->local_blks_read, es);
ExplainPropertyInteger("Local Dirtied Blocks",
usage->local_blks_dirtied, es);
ExplainPropertyInteger("Local Written Blocks",
usage->local_blks_written, es);
ExplainPropertyInteger("Temp Read Blocks",
usage->temp_blks_read, es);
ExplainPropertyInteger("Temp Written Blocks",
usage->temp_blks_written, es);
if (track_io_timing) if (track_io_timing)
{ {
ExplainPropertyFloat("I/O Read Time", INSTR_TIME_GET_MILLISEC(usage->blk_read_time), 3, es); 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) ...@@ -3309,23 +3322,11 @@ ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
* Explain an integer-valued property. * Explain an integer-valued property.
*/ */
void void
ExplainPropertyInteger(const char *qlabel, int value, ExplainState *es) ExplainPropertyInteger(const char *qlabel, int64 value, ExplainState *es)
{
char buf[32];
snprintf(buf, sizeof(buf), "%d", value);
ExplainProperty(qlabel, buf, true, es);
}
/*
* Explain a long-integer-valued property.
*/
void
ExplainPropertyLong(const char *qlabel, long value, ExplainState *es)
{ {
char buf[32]; char buf[32];
snprintf(buf, sizeof(buf), "%ld", value); snprintf(buf, sizeof(buf), INT64_FORMAT, value);
ExplainProperty(qlabel, buf, true, es); ExplainProperty(qlabel, buf, true, es);
} }
......
...@@ -93,9 +93,7 @@ extern void ExplainPropertyListNested(const char *qlabel, List *data, ...@@ -93,9 +93,7 @@ extern void ExplainPropertyListNested(const char *qlabel, List *data,
ExplainState *es); ExplainState *es);
extern void ExplainPropertyText(const char *qlabel, const char *value, extern void ExplainPropertyText(const char *qlabel, const char *value,
ExplainState *es); ExplainState *es);
extern void ExplainPropertyInteger(const char *qlabel, int value, extern void ExplainPropertyInteger(const char *qlabel, int64 value,
ExplainState *es);
extern void ExplainPropertyLong(const char *qlabel, long value,
ExplainState *es); ExplainState *es);
extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits, extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
ExplainState *es); ExplainState *es);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment