MCPcopy Create free account
hub / github.com/documentdb/documentdb / GetSortDetails

Function GetSortDetails

pg_documentdb/src/opclass/index_support.c:2681–2868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2679
2680
2681static List *
2682GetSortDetails(PlannerInfo *root, Index rti,
2683 bool *hasOrderBy, bool *hasGroupby, bool *isOrderById)
2684{
2685 List *sortDetails = NIL;
2686 ListCell *sortCell;
2687 foreach(sortCell, root->query_pathkeys)
2688 {
2689 PathKey *pathkey = (PathKey *) lfirst(sortCell);
2690 if (pathkey->pk_eclass == NULL ||
2691 list_length(pathkey->pk_eclass->ec_members) != 1)
2692 {
2693 return NIL;
2694 }
2695
2696 EquivalenceMember *member = linitial(pathkey->pk_eclass->ec_members);
2697
2698 if (!IsA(member->em_expr, FuncExpr))
2699 {
2700 return NIL;
2701 }
2702
2703 FuncExpr *func = (FuncExpr *) member->em_expr;
2704 if (func->funcid == BsonOrderByFunctionOid())
2705 {
2706 if (*hasGroupby)
2707 {
2708 break;
2709 }
2710
2711 *hasOrderBy = true;
2712 }
2713 else if (EnableOrderByIndexTerm &&
2714 (func->funcid == BsonOrderByIndexFunctionOid() ||
2715 func->funcid == BsonOrderByIndexReverseFunctionOid()))
2716 {
2717 /* TODO: Collation index pushdown support. */
2718 if (*hasGroupby)
2719 {
2720 break;
2721 }
2722
2723 *hasOrderBy = true;
2724 }
2725 else if (func->funcid == BsonExpressionGetFunctionOid() ||
2726 func->funcid == BsonExpressionGetWithLetFunctionOid())
2727 {
2728 if (*hasOrderBy)
2729 {
2730 return NIL;
2731 }
2732
2733 *hasGroupby = true;
2734 }
2735 else if (func->funcid == DocumentDBCoreBsonToBsonFunctionOId())
2736 {
2737 Expr *firstArg = linitial(func->args);
2738 if (!IsA(firstArg, FuncExpr))

Callers 3

ProcessOrderByStatementsFunction · 0.85

Tested by

no test coverage detected