* 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. */
| 159 | * comparator function pointer. |
| 160 | */ |
| 161 | void |
| 162 | PrepareSortSupportFromIndexRel(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 |
no test coverage detected