Commit 6ee3b5fb authored by David Rowley's avatar David Rowley

Use int64 instead of long in incremental sort code

Windows 64bit has 4-byte long values which is not suitable for tracking
disk space usage in the incremental sort code. Let's just make all these
fields int64s.

Author: James Coleman
Discussion: https://postgr.es/m/CAApHDvpky%2BUhof8mryPf5i%3D6e6fib2dxHqBrhp0Qhu0NeBhLJw%40mail.gmail.com
Backpatch-through: 13, where the incremental sort code was added
parent cd5e8225
...@@ -2676,7 +2676,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2676,7 +2676,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
TuplesortInstrumentation stats; TuplesortInstrumentation stats;
const char *sortMethod; const char *sortMethod;
const char *spaceType; const char *spaceType;
long spaceUsed; int64 spaceUsed;
tuplesort_get_stats(state, &stats); tuplesort_get_stats(state, &stats);
sortMethod = tuplesort_method_name(stats.sortMethod); sortMethod = tuplesort_method_name(stats.sortMethod);
...@@ -2686,7 +2686,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2686,7 +2686,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
if (es->format == EXPLAIN_FORMAT_TEXT) if (es->format == EXPLAIN_FORMAT_TEXT)
{ {
ExplainIndentText(es); ExplainIndentText(es);
appendStringInfo(es->str, "Sort Method: %s %s: %ldkB\n", appendStringInfo(es->str, "Sort Method: %s %s: " INT64_FORMAT "kB\n",
sortMethod, spaceType, spaceUsed); sortMethod, spaceType, spaceUsed);
} }
else else
...@@ -2715,7 +2715,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2715,7 +2715,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
TuplesortInstrumentation *sinstrument; TuplesortInstrumentation *sinstrument;
const char *sortMethod; const char *sortMethod;
const char *spaceType; const char *spaceType;
long spaceUsed; int64 spaceUsed;
sinstrument = &sortstate->shared_info->sinstrument[n]; sinstrument = &sortstate->shared_info->sinstrument[n];
if (sinstrument->sortMethod == SORT_TYPE_STILL_IN_PROGRESS) if (sinstrument->sortMethod == SORT_TYPE_STILL_IN_PROGRESS)
...@@ -2731,7 +2731,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) ...@@ -2731,7 +2731,7 @@ show_sort_info(SortState *sortstate, ExplainState *es)
{ {
ExplainIndentText(es); ExplainIndentText(es);
appendStringInfo(es->str, appendStringInfo(es->str,
"Sort Method: %s %s: %ldkB\n", "Sort Method: %s %s: " INT64_FORMAT "kB\n",
sortMethod, spaceType, spaceUsed); sortMethod, spaceType, spaceUsed);
} }
else else
...@@ -2795,23 +2795,23 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo, ...@@ -2795,23 +2795,23 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo,
if (groupInfo->maxMemorySpaceUsed > 0) if (groupInfo->maxMemorySpaceUsed > 0)
{ {
long avgSpace = groupInfo->totalMemorySpaceUsed / groupInfo->groupCount; int64 avgSpace = groupInfo->totalMemorySpaceUsed / groupInfo->groupCount;
const char *spaceTypeName; const char *spaceTypeName;
spaceTypeName = tuplesort_space_type_name(SORT_SPACE_TYPE_MEMORY); spaceTypeName = tuplesort_space_type_name(SORT_SPACE_TYPE_MEMORY);
appendStringInfo(es->str, " Average %s: %ldkB Peak %s: %ldkB", appendStringInfo(es->str, " Average %s: " INT64_FORMAT "kB Peak %s: " INT64_FORMAT "kB",
spaceTypeName, avgSpace, spaceTypeName, avgSpace,
spaceTypeName, groupInfo->maxMemorySpaceUsed); spaceTypeName, groupInfo->maxMemorySpaceUsed);
} }
if (groupInfo->maxDiskSpaceUsed > 0) if (groupInfo->maxDiskSpaceUsed > 0)
{ {
long avgSpace = groupInfo->totalDiskSpaceUsed / groupInfo->groupCount; int64 avgSpace = groupInfo->totalDiskSpaceUsed / groupInfo->groupCount;
const char *spaceTypeName; const char *spaceTypeName;
spaceTypeName = tuplesort_space_type_name(SORT_SPACE_TYPE_DISK); spaceTypeName = tuplesort_space_type_name(SORT_SPACE_TYPE_DISK);
appendStringInfo(es->str, " Average %s: %ldkB Peak %s: %ldkB", appendStringInfo(es->str, " Average %s: " INT64_FORMAT "kB Peak %s: " INT64_FORMAT "kB",
spaceTypeName, avgSpace, spaceTypeName, avgSpace,
spaceTypeName, groupInfo->maxDiskSpaceUsed); spaceTypeName, groupInfo->maxDiskSpaceUsed);
} }
...@@ -2829,7 +2829,7 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo, ...@@ -2829,7 +2829,7 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo,
if (groupInfo->maxMemorySpaceUsed > 0) if (groupInfo->maxMemorySpaceUsed > 0)
{ {
long avgSpace = groupInfo->totalMemorySpaceUsed / groupInfo->groupCount; int64 avgSpace = groupInfo->totalMemorySpaceUsed / groupInfo->groupCount;
const char *spaceTypeName; const char *spaceTypeName;
StringInfoData memoryName; StringInfoData memoryName;
...@@ -2846,7 +2846,7 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo, ...@@ -2846,7 +2846,7 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo,
} }
if (groupInfo->maxDiskSpaceUsed > 0) if (groupInfo->maxDiskSpaceUsed > 0)
{ {
long avgSpace = groupInfo->totalDiskSpaceUsed / groupInfo->groupCount; int64 avgSpace = groupInfo->totalDiskSpaceUsed / groupInfo->groupCount;
const char *spaceTypeName; const char *spaceTypeName;
StringInfoData diskName; StringInfoData diskName;
......
...@@ -2032,10 +2032,10 @@ typedef struct SortState ...@@ -2032,10 +2032,10 @@ typedef struct SortState
typedef struct IncrementalSortGroupInfo typedef struct IncrementalSortGroupInfo
{ {
int64 groupCount; int64 groupCount;
long maxDiskSpaceUsed; int64 maxDiskSpaceUsed;
long totalDiskSpaceUsed; int64 totalDiskSpaceUsed;
long maxMemorySpaceUsed; int64 maxMemorySpaceUsed;
long totalMemorySpaceUsed; int64 totalMemorySpaceUsed;
bits32 sortMethods; /* bitmask of TuplesortMethod */ bits32 sortMethods; /* bitmask of TuplesortMethod */
} IncrementalSortGroupInfo; } IncrementalSortGroupInfo;
......
...@@ -90,7 +90,7 @@ typedef struct TuplesortInstrumentation ...@@ -90,7 +90,7 @@ typedef struct TuplesortInstrumentation
{ {
TuplesortMethod sortMethod; /* sort algorithm used */ TuplesortMethod sortMethod; /* sort algorithm used */
TuplesortSpaceType spaceType; /* type of space spaceUsed represents */ TuplesortSpaceType spaceType; /* type of space spaceUsed represents */
long spaceUsed; /* space consumption, in kB */ int64 spaceUsed; /* space consumption, in kB */
} TuplesortInstrumentation; } TuplesortInstrumentation;
......
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