| 3849 | |
| 3850 | |
| 3851 | static Datum |
| 3852 | BsonDollarInCore(PG_FUNCTION_ARGS, bool hasObjectIdArg) |
| 3853 | { |
| 3854 | pgbson *document = PG_GETARG_PGBSON(0); |
| 3855 | bson_iter_t documentIterator; |
| 3856 | TraverseInValidateState state = { 0 }; |
| 3857 | |
| 3858 | pgbsonelement filterElement = { 0 }; |
| 3859 | PopulateDollarInValidationState(fcinfo, &state, &filterElement, hasObjectIdArg); |
| 3860 | |
| 3861 | PgbsonInitIterator(document, &documentIterator); |
| 3862 | |
| 3863 | TraverseBson(&documentIterator, filterElement.path, &state.traverseState, |
| 3864 | &CompareExecutionFuncs); |
| 3865 | if (state.hasNull) |
| 3866 | { |
| 3867 | /* If any element in the input is null and the target path cannot be found in the document, we'll choose that document. */ |
| 3868 | PG_RETURN_BOOL(state.traverseState.compareResult != CompareResult_Mismatch); |
| 3869 | } |
| 3870 | else |
| 3871 | { |
| 3872 | PG_RETURN_BOOL(state.traverseState.compareResult == CompareResult_Match); |
| 3873 | } |
| 3874 | } |
| 3875 | |
| 3876 | |
| 3877 | /* |
no test coverage detected