MCPcopy Create free account
hub / github.com/apache/cloudberry / PrepareSortSupportFromIndexRel

Function PrepareSortSupportFromIndexRel

src/backend/utils/sort/sortsupport.c:161–178  ·  view source on GitHub ↗

* Fill in SortSupport given an index relation, attribute, and strategy. * * Caller must previously have zeroed the SortSupportData structure and then * filled in ssup_cxt, ssup_attno, ssup_collation, and ssup_nulls_first. This * will fill in ssup_reverse (based on the supplied strategy), as well as the * comparator function pointer. */

Source from the content-addressed store, hash-verified

159 * comparator function pointer.
160 */
161void
162PrepareSortSupportFromIndexRel(Relation indexRel, int16 strategy,
163 SortSupport ssup)
164{
165 Oid opfamily = indexRel->rd_opfamily[ssup->ssup_attno - 1];
166 Oid opcintype = indexRel->rd_opcintype[ssup->ssup_attno - 1];
167
168 Assert(ssup->comparator == NULL);
169
170 if (!IsIndexAccessMethod(indexRel->rd_rel->relam, BTREE_AM_OID))
171 elog(ERROR, "unexpected non-btree AM: %u", indexRel->rd_rel->relam);
172 if (strategy != BTGreaterStrategyNumber &&
173 strategy != BTLessStrategyNumber)
174 elog(ERROR, "unexpected sort support strategy: %d", strategy);
175 ssup->ssup_reverse = (strategy == BTGreaterStrategyNumber);
176
177 FinishSortSupportFunction(opfamily, opcintype, ssup);
178}
179
180/*
181 * Fill in SortSupport given a GiST index relation

Callers 3

tuplesort_begin_clusterFunction · 0.85
_bt_loadFunction · 0.85

Calls 2

IsIndexAccessMethodFunction · 0.85

Tested by

no test coverage detected