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

Function PopulateRegexState

pg_documentdb/src/query/bson_dollar_operators.c:3513–3538  ·  view source on GitHub ↗

* Given a top level function arguments for regex and a traverse state for * regex, populates the data inside the validation state. */

Source from the content-addressed store, hash-verified

3511 * regex, populates the data inside the validation state.
3512 */
3513static pgbsonelement
3514PopulateRegexState(PG_FUNCTION_ARGS, TraverseRegexValidateState *state)
3515{
3516 pgbson *filter = PG_GETARG_PGBSON(1);
3517 const RegexData *regexState;
3518 pgbsonelement filterElement;
3519
3520 /* collation does not take effect on $regex */
3521 PgbsonToSinglePgbsonElement(filter, &filterElement);
3522
3523 /* State populated if and only if cached state is unusable */
3524 SetCachedFunctionState(regexState, RegexData, 1, PopulateRegexFromQuery,
3525 &filterElement);
3526 if (regexState == NULL)
3527 {
3528 /* Cache not available */
3529 PopulateRegexFromQuery(&state->regexData, &filterElement);
3530 }
3531 else
3532 {
3533 state->regexData = *regexState;
3534 }
3535
3536 state->traverseState.matchFunc = CompareRegexMatch;
3537 return filterElement;
3538}
3539
3540
3541/*

Callers 2

bson_dollar_regexFunction · 0.85
bson_value_dollar_regexFunction · 0.85

Calls 2

PopulateRegexFromQueryFunction · 0.85

Tested by

no test coverage detected