* bson_dollar_unwind takes: * 1) a bson document * 2) a dot notation field path to the purported array * 3) an optional text for an index field in the output * 4) a boolean indicating whether to preserve null and empty arrays */
| 139 | * 4) a boolean indicating whether to preserve null and empty arrays |
| 140 | */ |
| 141 | Datum |
| 142 | bson_dollar_unwind(PG_FUNCTION_ARGS) |
| 143 | { |
| 144 | char *indexFieldName = NULL; |
| 145 | bool preserveNullAndEmpty = false; |
| 146 | |
| 147 | TupleDesc descriptor; |
| 148 | Tuplestorestate *tupleStore = SetupBsonTuplestore(fcinfo, &descriptor); |
| 149 | |
| 150 | return BsonUnwindArray(fcinfo, tupleStore, &descriptor, text_to_cstring( |
| 151 | PG_GETARG_TEXT_PP(1)), indexFieldName, |
| 152 | preserveNullAndEmpty); |
| 153 | } |
| 154 | |
| 155 | |
| 156 | /* |
nothing calls this directly
no test coverage detected