* Utility function that iterates on the index keyDocument pgbson and returns the index plugin * name upon finding the first match. If no match is found, return "regular". */
| 2323 | * name upon finding the first match. If no match is found, return "regular". |
| 2324 | */ |
| 2325 | const char * |
| 2326 | GetIndexTypeFromKeyDocument(pgbson *keyDocument) |
| 2327 | { |
| 2328 | const char *regularIndexType = "regular"; |
| 2329 | |
| 2330 | /* Assume document is of regular type if pgbson is NULL.*/ |
| 2331 | if (keyDocument == NULL) |
| 2332 | { |
| 2333 | return regularIndexType; |
| 2334 | } |
| 2335 | |
| 2336 | bson_iter_t iter; |
| 2337 | PgbsonInitIterator(keyDocument, &iter); |
| 2338 | while (bson_iter_next(&iter)) |
| 2339 | { |
| 2340 | const bson_value_t *value = bson_iter_value(&iter); |
| 2341 | for (int i = 0; i < NumberOfMongoIndexTypes; i++) |
| 2342 | { |
| 2343 | MongoIndexSupport idxSupport = MongoIndexSupportedList[i]; |
| 2344 | if (IsIndexOfType(value, idxSupport.mongoIndexName)) |
| 2345 | { |
| 2346 | return idxSupport.mongoIndexName; |
| 2347 | } |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | return regularIndexType; |
| 2352 | } |
| 2353 | |
| 2354 | |
| 2355 | /* |
nothing calls this directly
no test coverage detected