MCPcopy Create free account
hub / github.com/documentdb/documentdb / ValidateInputBsonBytes

Function ValidateInputBsonBytes

pg_documentdb_core/src/io/pgbson.c:502–522  ·  view source on GitHub ↗

* Validates a user input bson as bytes to ensure it's compatible with the database. * This includes validating field names for the specified flags. */

Source from the content-addressed store, hash-verified

500 * This includes validating field names for the specified flags.
501 */
502void
503ValidateInputBsonBytes(const uint8_t *documentBytes,
504 uint32_t documentBytesLength,
505 bson_validate_flags_t validateFlag)
506{
507 bson_t bson;
508 if (!bson_init_static(&bson, documentBytes, documentBytesLength))
509 {
510 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
511 errmsg(
512 "invalid input syntax for BSON: Unable to initialize for validate")));
513 }
514
515 bson_error_t error;
516 if (!bson_validate_with_error(&bson, validateFlag, &error))
517 {
518 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
519 errmsg("invalid input syntax for BSON. Code: %u, Message %s",
520 error.code, error.message)));
521 }
522}
523
524
525/*

Callers 2

PgbsonValidateInputBsonFunction · 0.85
ProcessReplaceDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected