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

Function GetIndexBoundsForExplain

pg_documentdb/src/index_am/rum.c:1536–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1534
1535
1536static List *
1537GetIndexBoundsForExplain(Relation index_rel, Datum compositeArgDatum, bool hasOrderBy,
1538 List **rawPerPathBounds)
1539{
1540 uint32_t nentries = 0;
1541 bool *partialMatch = NULL;
1542 Pointer *extraData = NULL;
1543
1544 /* From the composite keys, get the lower bounds of the scans */
1545 /* Call extract_query to get the index details */
1546 int32_t ginScanType = hasOrderBy ? GIN_SEARCH_MODE_ALL :
1547 GIN_SEARCH_MODE_DEFAULT;
1548 LOCAL_FCINFO(fcinfo, 7);
1549 fcinfo->flinfo = palloc(sizeof(FmgrInfo));
1550 fmgr_info_copy(fcinfo->flinfo,
1551 index_getprocinfo(index_rel, 1,
1552 GIN_EXTRACTQUERY_PROC),
1553 CurrentMemoryContext);
1554
1555 fcinfo->args[0].value = compositeArgDatum;
1556 fcinfo->args[1].value = PointerGetDatum(&nentries);
1557 fcinfo->args[2].value = Int16GetDatum(BSON_INDEX_STRATEGY_COMPOSITE_QUERY);
1558 fcinfo->args[3].value = PointerGetDatum(&partialMatch);
1559 fcinfo->args[4].value = PointerGetDatum(&extraData);
1560 fcinfo->args[6].value = PointerGetDatum(&ginScanType);
1561
1562 Datum *entryRes = (Datum *) gin_bson_composite_path_extract_query(fcinfo);
1563
1564 /* Now write out the result for explain */
1565 List *boundsList = NIL;
1566 for (uint32_t i = 0; i < nentries; i++)
1567 {
1568 bytea *entry = DatumGetByteaPP(entryRes[i]);
1569
1570 if (IsSerializedRootTruncationTerm(entry))
1571 {
1572 continue;
1573 }
1574
1575 List *rawPathBoundsInner = NIL;
1576 char *serializedBound = SerializeBoundsStringForExplain(entry,
1577 extraData[i],
1578 fcinfo,
1579 &rawPathBoundsInner);
1580 boundsList = lappend(boundsList, serializedBound);
1581 if (rawPathBoundsInner != NIL)
1582 {
1583 *rawPerPathBounds = list_concat(*rawPerPathBounds, rawPathBoundsInner);
1584 }
1585 }
1586
1587 return boundsList;
1588}
1589
1590
1591static void

Callers 2

ExplainCompositeScanCoreFunction · 0.85

Tested by

no test coverage detected