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

Function IndexKeyGetMatchingIndexesCore

pg_documentdb/src/metadata/index.c:1009–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1007
1008
1009static List *
1010IndexKeyGetMatchingIndexesCore(const char *cmdStr, uint64 collectionId, const
1011 pgbson *indexKeyDocument)
1012{
1013 int argCount = 2;
1014 Oid argTypes[2];
1015 Datum argValues[2];
1016
1017 argTypes[0] = INT8OID;
1018 argValues[0] = UInt64GetDatum(collectionId);
1019
1020 argTypes[1] = BsonTypeId();
1021 argValues[1] = PointerGetDatum(indexKeyDocument);
1022
1023 /* all args are non-null */
1024 char *argNulls = NULL;
1025
1026 bool readOnly = true;
1027
1028 int numValues = 3;
1029 bool isNull[3];
1030 Datum results[3];
1031 ExtensionExecuteMultiValueQueryWithArgsViaSPI(cmdStr, argCount, argTypes,
1032 argValues, argNulls, readOnly,
1033 SPI_OK_SELECT, results, isNull,
1034 numValues);
1035
1036 if (isNull[0])
1037 {
1038 return NIL;
1039 }
1040
1041 ArrayType *indexIdArray = DatumGetArrayTypeP(results[0]);
1042 ArrayType *indexSpecArray = DatumGetArrayTypeP(results[1]);
1043 ArrayType *indexBuildInProgressArray = DatumGetArrayTypeP(results[2]);
1044
1045 /* error if any Datums are NULL */
1046 bool **nulls = NULL;
1047
1048 Datum *indexIdArrayElems = NULL;
1049 int nIndexIdArrayElems = 0;
1050 ArrayExtractDatums(indexIdArray, INT4OID, &indexIdArrayElems, nulls,
1051 &nIndexIdArrayElems);
1052
1053 Datum *indexSpecArrayElems = NULL;
1054 int nIndexSpecArrayElems = 0;
1055 ArrayExtractDatums(indexSpecArray, IndexSpecTypeId(), &indexSpecArrayElems, nulls,
1056 &nIndexSpecArrayElems);
1057
1058 Assert(nIndexIdArrayElems == nIndexSpecArrayElems);
1059
1060 Datum *indexBuildProgressArrayElems = NULL;
1061 int nIndexIsValidArrayElems = 0;
1062 ArrayExtractDatums(indexBuildInProgressArray, BOOLOID, &indexBuildProgressArrayElems,
1063 nulls,
1064 &nIndexIsValidArrayElems);
1065 Assert(nIndexIsValidArrayElems == nIndexIdArrayElems);
1066

Callers 2

Calls 5

BsonTypeIdFunction · 0.85
ArrayExtractDatumsFunction · 0.85
IndexSpecTypeIdFunction · 0.85
DatumGetIndexSpecFunction · 0.85

Tested by

no test coverage detected