* Checks if a collection has extended stats enabled. We do this by checking the index option * for the primary key index in the index catalog. */
| 2930 | * for the primary key index in the index catalog. |
| 2931 | */ |
| 2932 | bool |
| 2933 | CollectionHasStatisticsEnabled(uint64 collectionId) |
| 2934 | { |
| 2935 | /* Find the _id index (the primary key index for the collection) */ |
| 2936 | IndexDetails *details = IndexNameGetIndexDetails(collectionId, "_id_"); |
| 2937 | if (details == NULL) |
| 2938 | { |
| 2939 | return false; |
| 2940 | } |
| 2941 | |
| 2942 | pgbson *indexOptions = details->indexSpec.indexOptions; |
| 2943 | if (indexOptions == NULL) |
| 2944 | { |
| 2945 | return false; |
| 2946 | } |
| 2947 | |
| 2948 | bson_iter_t iter; |
| 2949 | if (!PgbsonInitIteratorAtPath(indexOptions, "statsEnabled", &iter)) |
| 2950 | { |
| 2951 | return false; |
| 2952 | } |
| 2953 | |
| 2954 | return bson_iter_as_bool(&iter); |
| 2955 | } |
| 2956 | |
| 2957 | |
| 2958 | static void |
no test coverage detected