* Looks at the "raw" Mongo collection and extracts the * actual Mongo database/collection. */
| 1139 | * actual Mongo database/collection. |
| 1140 | */ |
| 1141 | static void |
| 1142 | DetectMongoCollection(SingleWorkerActivity *activity) |
| 1143 | { |
| 1144 | activity->processedMongoDatabase = ""; |
| 1145 | activity->processedMongoCollection = ""; |
| 1146 | if (activity->rawMongoTable == NULL && |
| 1147 | (strstr(activity->query, "CREATE INDEX") != NULL)) |
| 1148 | { |
| 1149 | /* Get Index Spec for sharded create index query, for this activity->rawMongoTable could be null */ |
| 1150 | IndexSpec *spec = GetIndexSpecForShardedCreateIndexQuery(activity); |
| 1151 | if (spec != NULL) |
| 1152 | { |
| 1153 | activity->indexSpec = spec; |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | /* No raw collection found */ |
| 1158 | if (activity->rawMongoTable == NULL || |
| 1159 | strlen(activity->rawMongoTable) < 11 || |
| 1160 | strncmp(activity->rawMongoTable, "documents_", 10) != 0) |
| 1161 | { |
| 1162 | return; |
| 1163 | } |
| 1164 | |
| 1165 | uint64 collectionId = (uint64) atoll(&activity->rawMongoTable[10]); |
| 1166 | if (collectionId == 0) |
| 1167 | { |
| 1168 | return; |
| 1169 | } |
| 1170 | |
| 1171 | const MongoCollection *collection = GetMongoCollectionByColId(collectionId, NoLock); |
| 1172 | if (collection != NULL) |
| 1173 | { |
| 1174 | activity->processedMongoDatabase = collection->name.databaseName; |
| 1175 | activity->processedMongoCollection = collection->name.collectionName; |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | |
| 1180 | /* |
no test coverage detected