* MakeIndexSpecForBuiltinIdIndex returns an IndexSpec for a built-in _id index. */
| 1226 | * MakeIndexSpecForBuiltinIdIndex returns an IndexSpec for a built-in _id index. |
| 1227 | */ |
| 1228 | IndexSpec |
| 1229 | MakeIndexSpecForBuiltinIdIndex(void) |
| 1230 | { |
| 1231 | pgbson_writer indexKeyDocumentWriter; |
| 1232 | PgbsonWriterInit(&indexKeyDocumentWriter); |
| 1233 | int idIndexOrdering = 1; |
| 1234 | PgbsonWriterAppendInt32(&indexKeyDocumentWriter, ID_FIELD_KEY, |
| 1235 | strlen(ID_FIELD_KEY), idIndexOrdering); |
| 1236 | |
| 1237 | IndexSpec idIndexSpec = { |
| 1238 | .indexName = ID_INDEX_NAME, |
| 1239 | .indexVersion = 2, |
| 1240 | .indexKeyDocument = PgbsonWriterGetPgbson(&indexKeyDocumentWriter), |
| 1241 | .indexPFEDocument = NULL, |
| 1242 | .indexWPDocument = NULL, |
| 1243 | .indexSparse = BoolIndexOption_Undefined, |
| 1244 | |
| 1245 | /* |
| 1246 | * Even though the _id index is unique, Mongo (and we) report it as |
| 1247 | * "non unique". This is especially true in Sharded collections where |
| 1248 | * it's only unique by shard key. |
| 1249 | */ |
| 1250 | .indexUnique = BoolIndexOption_Undefined, |
| 1251 | .indexExpireAfterSeconds = NULL, |
| 1252 | .cosmosSearchOptions = NULL, |
| 1253 | .indexOptions = NULL |
| 1254 | }; |
| 1255 | |
| 1256 | return idIndexSpec; |
| 1257 | } |
| 1258 | |
| 1259 | |
| 1260 | /* |
no test coverage detected