* We need to use all the available indexes for text queries as * these can be used in OR clauses. And BitmapOrPath requires * the indexes in all the OR arms to be present otherwise it can't * create a BitmapOrPath. * e.g. {$or [{$text: ..., a: 2}, {other: 1}]}. This needs to have * an index on `other` so that this text query can be pushed to the index. * * more info at generate_bitmap_or_pa
| 4993 | * more info at generate_bitmap_or_paths |
| 4994 | */ |
| 4995 | static List * |
| 4996 | UpdateIndexListForText(List *existingIndex, ReplaceExtensionFunctionContext *context) |
| 4997 | { |
| 4998 | ListCell *indexCell; |
| 4999 | bool isValidTextIndexFound = false; |
| 5000 | foreach(indexCell, existingIndex) |
| 5001 | { |
| 5002 | IndexOptInfo *index = lfirst_node(IndexOptInfo, indexCell); |
| 5003 | if (IsBsonRegularIndexAm(index->relam) && |
| 5004 | index->nkeycolumns > 0) |
| 5005 | { |
| 5006 | for (int i = 0; i < index->nkeycolumns; i++) |
| 5007 | { |
| 5008 | if (IsTextPathOpFamilyOid(index->relam, index->opfamily[i])) |
| 5009 | { |
| 5010 | isValidTextIndexFound = true; |
| 5011 | QueryTextIndexData *textIndexData = |
| 5012 | (QueryTextIndexData *) context->forceIndexQueryOpData.opExtraState; |
| 5013 | if (textIndexData == NULL) |
| 5014 | { |
| 5015 | textIndexData = palloc0(sizeof(QueryTextIndexData)); |
| 5016 | context->forceIndexQueryOpData.opExtraState = |
| 5017 | (void *) textIndexData; |
| 5018 | } |
| 5019 | textIndexData->indexOptions = index->opclassoptions[i]; |
| 5020 | |
| 5021 | break; |
| 5022 | } |
| 5023 | } |
| 5024 | } |
| 5025 | } |
| 5026 | |
| 5027 | if (!isValidTextIndexFound) |
| 5028 | { |
| 5029 | ThrowNoTextIndexFound(); |
| 5030 | } |
| 5031 | |
| 5032 | return existingIndex; |
| 5033 | } |
| 5034 | |
| 5035 | |
| 5036 | /* |
nothing calls this directly
no test coverage detected