* PgbsonCountKeys returns the number of keys in a given bson document. */
| 69 | * PgbsonCountKeys returns the number of keys in a given bson document. |
| 70 | */ |
| 71 | int |
| 72 | PgbsonCountKeys(const pgbson *bsonDocument) |
| 73 | { |
| 74 | bson_t bson; |
| 75 | if (!bson_init_static(&bson, (const uint8_t *) VARDATA_ANY(bsonDocument), |
| 76 | VARSIZE_ANY_EXHDR(bsonDocument))) |
| 77 | { |
| 78 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE), |
| 79 | errmsg("invalid input syntax for BSON"))); |
| 80 | } |
| 81 | |
| 82 | return bson_count_keys(&bson); |
| 83 | } |
| 84 | |
| 85 | |
| 86 | /* |
no outgoing calls
no test coverage detected