* bson_get_value returns the value of a path within a BSON document as another * BSON document. */
| 208 | * BSON document. |
| 209 | */ |
| 210 | Datum |
| 211 | bson_get_value(PG_FUNCTION_ARGS) |
| 212 | { |
| 213 | pgbson *document = PG_GETARG_PGBSON(0); |
| 214 | char *path = text_to_cstring(PG_GETARG_TEXT_PP(1)); |
| 215 | bson_iter_t pathIterator; |
| 216 | |
| 217 | if (PgbsonInitIteratorAtPath(document, path, &pathIterator)) |
| 218 | { |
| 219 | const bson_value_t *value = bson_iter_value(&pathIterator); |
| 220 | PG_RETURN_POINTER(BsonValueToDocumentPgbson(value)); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | PG_RETURN_NULL(); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | |
| 229 | /* |
nothing calls this directly
no test coverage detected