MCPcopy Create free account
hub / github.com/documentdb/documentdb / AreIndexOptionsStillEquivalent

Function AreIndexOptionsStillEquivalent

pg_documentdb/src/metadata/index.c:2788–2846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2786
2787
2788static bool
2789AreIndexOptionsStillEquivalent(const char *path, const bson_value_t *left,
2790 const bson_value_t *right)
2791{
2792 bool areEquivalent = true;
2793 if (IsOptionsKeyOrderedIndex(path))
2794 {
2795 if (left != NULL || right != NULL)
2796 {
2797 bool enableCompositeTermLeft = false;
2798 bool enableCompositeTermRight = false;
2799
2800 if (left != NULL)
2801 {
2802 enableCompositeTermLeft = BsonValueAsBool(left);
2803 }
2804 if (right != NULL)
2805 {
2806 enableCompositeTermRight = BsonValueAsBool(right);
2807 }
2808
2809 areEquivalent = enableCompositeTermLeft == enableCompositeTermRight;
2810 }
2811 }
2812
2813 if (areEquivalent && strcmp(path, "buildAsUnique") == 0)
2814 {
2815 if (left != NULL || right != NULL)
2816 {
2817 bool buildAsUniqueLeft = false;
2818 bool buildAsUniqueRight = false;
2819
2820 if (left != NULL)
2821 {
2822 buildAsUniqueLeft = BsonValueAsBool(left);
2823 }
2824 if (right != NULL)
2825 {
2826 buildAsUniqueRight = BsonValueAsBool(right);
2827 }
2828
2829 areEquivalent = buildAsUniqueLeft == buildAsUniqueRight;
2830 }
2831 }
2832
2833 if (areEquivalent && strcmp(path, "collation") == 0)
2834 {
2835 if (left == NULL || right == NULL)
2836 {
2837 areEquivalent = left == right;
2838 }
2839 else
2840 {
2841 areEquivalent = BsonValueEquals(left, right);
2842 }
2843 }
2844
2845 return areEquivalent;

Callers 1

Calls 3

IsOptionsKeyOrderedIndexFunction · 0.85
BsonValueAsBoolFunction · 0.85
BsonValueEqualsFunction · 0.85

Tested by

no test coverage detected