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

Function ValidateShardKey

pg_documentdb/src/sharding/sharding.c:437–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435
436
437static void
438ValidateShardKey(const pgbson *shardKeyDoc)
439{
440 bson_iter_t shardKeyIterator;
441 PgbsonInitIterator(shardKeyDoc, &shardKeyIterator);
442
443 while (bson_iter_next(&shardKeyIterator))
444 {
445 const bson_value_t *value = bson_iter_value(&shardKeyIterator);
446
447 if (value->value_type == BSON_TYPE_UTF8)
448 {
449 if (strcmp("hashed", value->value.v_utf8.str) != 0)
450 {
451 ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
452 errmsg("Shard key value provided is invalid: %s",
453 value->value.v_utf8.str)));
454 }
455 }
456 else
457 {
458 ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
459 errmsg("only shard keys that use hashed are supported")));
460 }
461 }
462}
463
464
465static void

Callers 4

ShardCollectionLegacyFunction · 0.85

Calls 1

PgbsonInitIteratorFunction · 0.85

Tested by

no test coverage detected