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

Function CheckValidIdentifier

pg_documentdb/src/commands/kill_op.c:58–77  ·  view source on GitHub ↗

* Validated a number string to contain only digits. * Throws an error if invalid. */

Source from the content-addressed store, hash-verified

56 * Throws an error if invalid.
57 */
58static inline void
59CheckValidIdentifier(StringView *identifier, const char *fieldId)
60{
61 if (identifier == NULL || identifier->length == 0)
62 {
63 return;
64 }
65
66 for (uint32_t i = 0; i < identifier->length; i++)
67 {
68 if (identifier->string[i] < '0' || identifier->string[i] > '9')
69 {
70 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
71 errmsg("Invalid %s: %.*s", fieldId, identifier->length,
72 identifier->string),
73 errdetail_log("Invalid %s: %.*s", fieldId, identifier->length,
74 identifier->string)));
75 }
76 }
77}
78
79
80/*

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected