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

Commit d8cd68c

Browse files
Rename tuplesort.c's SortTuple.tupindex field.
Rename the "tupindex" field from tuplesort.c's SortTuple struct to "srctape", since it can only ever be used to store a source/input tape number when merging external sort runs. This has been the case since commit 8b304b8, which removed replacement selection sort from tuplesort.c.
1 parent 0662eb6 commit d8cd68c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/backend/utils/sort/tuplesort.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ bool optimize_bounded_sort = true;
141141
* which is a separate palloc chunk --- we assume it is just one chunk and
142142
* can be freed by a simple pfree() (except during merge, when we use a
143143
* simple slab allocator). SortTuples also contain the tuple's first key
144-
* column in Datum/nullflag format, and an index integer.
144+
* column in Datum/nullflag format, and a source/input tape number that
145+
* tracks which tape each heap element/slot belongs to during merging.
145146
*
146147
* Storing the first key column lets us save heap_getattr or index_getattr
147148
* calls during tuple comparisons. We could extract and save all the key
@@ -162,16 +163,13 @@ bool optimize_bounded_sort = true;
162163
* either the same pointer as "tuple", or is an abbreviated key value as
163164
* described above. Accordingly, "tuple" is always used in preference to
164165
* datum1 as the authoritative value for pass-by-reference cases.
165-
*
166-
* tupindex holds the input tape number that each tuple in the heap was read
167-
* from during merge passes.
168166
*/
169167
typedef struct
170168
{
171169
void *tuple; /* the tuple itself */
172170
Datum datum1; /* value of first key column */
173171
bool isnull1; /* is first key column NULL? */
174-
int tupindex; /* see notes above */
172+
int srctape; /* source tape number */
175173
} SortTuple;
176174

177175
/*
@@ -2093,7 +2091,7 @@ tuplesort_gettuple_common(Tuplesortstate *state, bool forward,
20932091
*/
20942092
if (state->memtupcount > 0)
20952093
{
2096-
int srcTape = state->memtuples[0].tupindex;
2094+
int srcTape = state->memtuples[0].srctape;
20972095
SortTuple newtup;
20982096

20992097
*stup = state->memtuples[0];
@@ -2124,7 +2122,7 @@ tuplesort_gettuple_common(Tuplesortstate *state, bool forward,
21242122
LogicalTapeRewindForWrite(state->tapeset, srcTape);
21252123
return true;
21262124
}
2127-
newtup.tupindex = srcTape;
2125+
newtup.srctape = srcTape;
21282126
tuplesort_heap_replace_top(state, &newtup);
21292127
return true;
21302128
}
@@ -2808,7 +2806,7 @@ mergeonerun(Tuplesortstate *state)
28082806
SortTuple stup;
28092807

28102808
/* write the tuple to destTape */
2811-
srcTape = state->memtuples[0].tupindex;
2809+
srcTape = state->memtuples[0].srctape;
28122810
WRITETUP(state, destTape, &state->memtuples[0]);
28132811

28142812
/* recycle the slot of the tuple we just wrote out, for the next read */
@@ -2821,7 +2819,7 @@ mergeonerun(Tuplesortstate *state)
28212819
*/
28222820
if (mergereadnext(state, srcTape, &stup))
28232821
{
2824-
stup.tupindex = srcTape;
2822+
stup.srctape = srcTape;
28252823
tuplesort_heap_replace_top(state, &stup);
28262824
}
28272825
else
@@ -2886,7 +2884,7 @@ beginmerge(Tuplesortstate *state)
28862884

28872885
if (mergereadnext(state, srcTape, &tup))
28882886
{
2889-
tup.tupindex = srcTape;
2887+
tup.srctape = srcTape;
28902888
tuplesort_heap_insert(state, &tup);
28912889
}
28922890
}

0 commit comments

Comments
 (0)