* For a given bson value of document type, converts to a pgbsonelement, * which contains the path and value at that path. */
| 229 | * which contains the path and value at that path. |
| 230 | */ |
| 231 | void |
| 232 | BsonValueToPgbsonElement(const bson_value_t *bsonValue, |
| 233 | pgbsonelement *element) |
| 234 | { |
| 235 | bson_iter_t iterator; |
| 236 | |
| 237 | Assert(bsonValue != NULL); |
| 238 | |
| 239 | if (!bson_iter_init_from_data(&iterator, |
| 240 | bsonValue->value.v_doc.data, |
| 241 | bsonValue->value.v_doc.data_len)) |
| 242 | { |
| 243 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE), |
| 244 | errmsg("Could not initialize bson iterator."))); |
| 245 | } |
| 246 | |
| 247 | if (!bson_iter_next(&iterator)) |
| 248 | { |
| 249 | ereport(ERROR, errmsg("invalid input BSON: Should not be empty document")); |
| 250 | } |
| 251 | BsonIterToPgbsonElement(&iterator, element); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | /* |
no test coverage detected