mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-26 04:09:50 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes (helio_api.enableCollation). Yes. ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) Done ### Description Runtime implementation of collation support in Mongo Find query. We parse the Mongo collation spec and covert it to an ICU standard collation string. An example string is "und-u-ks-level1-kc-true This string uniquely identify collation-based string comparison logic by Postgres. See: https://www.postgresql.org/docs/current/collation.html This document tracks the current support matrix for query operators | Operator | Runtime | Index Pushdown | Comments | --------- | ---- | ----- | ---- | $eq | Yes | No | | $gt | Yes | No | | $gte | Yes | No | | $lt | Yes | No | | $lte | Yes | No | | $ne | Yes | No | | $in | No* | No | See below | $nin | No* | No | Do | $and | Yes | No | | $not | Yes | No | | $nor | Yes | No | | $or | Yes | No | | $all | Yes | No | | $elemMatch | Yes | No | | $positional | N/A | N/A | positional query operators are only used in projections. | $regex | N/A | N/A | $regex ignores collations in Native Mongo | $exists | N/A | N/A | | $size | N/A | N/A | | $type | N/A | N/A | | $bitsAllClear | N/A | N/A | Not relevant for Utf8 | $bitsAnyClear | N/A | N/A | Do | $bitsAllSet | N/A | N/A | Do | $bitsAnySet | N/A | N/A | Do | $mod | N/A | N/A | Do | $range | N/A | N/A | Only applies to Number | $text | N/A | N/A | Seprate Index, has its own collation spec | $geowithin | N/A | N/A | Not relevant for Utf8 | $geointersects | N/A | N/A | Do * $in/$nin is implemented with HashMap that does not support collation friendly Hashkeys * $regex : collations are ignored with * $text: $text spec has collation specific parameters * $rage: For numbers only This document tracks the current support matrix for update operators/commands | Operator | Runtime | Index Pushdown | | --------- | ---- | ----- | | find_and_modify | No | No | | updateOne | No | No | | updateMany | No | No | | createIndex | No | No | Tests: 1. All Gated Tests pass when Collation is enabled by default TODO: 1. Index support [already implemented - but breaking down for easy review] 2. Persist collation info while collection created [already implemented - but breaking down for easy review] 3. $cond, $let Related work items: #3412359
45 lines
1.6 KiB
C
45 lines
1.6 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/bson/bson_expr_eval.h
|
|
*
|
|
* Common declarations of functions for handling expression evaluation on values for bson query expressions.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef BSON_EXPR_EVAL_H
|
|
#define BSON_EXPR_EVAL_H
|
|
|
|
#include "io/helio_bson_core.h"
|
|
|
|
typedef struct FuncExpr FuncExpr;
|
|
|
|
typedef struct ExprEvalState ExprEvalState;
|
|
|
|
ExprEvalState * GetExpressionEvalState(const bson_value_t *expression,
|
|
MemoryContext memoryContext);
|
|
ExprEvalState * GetExpressionEvalStateWithCollation(const bson_value_t *expression,
|
|
MemoryContext memoryContext, const
|
|
char *collationString);
|
|
|
|
ExprEvalState * GetExpressionEvalStateFromFuncExpr(const FuncExpr *expression,
|
|
MemoryContext memoryContext);
|
|
|
|
void FreeExprEvalState(ExprEvalState *exprEvalState, MemoryContext memoryContext);
|
|
|
|
bool EvalBooleanExpressionAgainstArray(ExprEvalState *evalState,
|
|
const bson_value_t *queryValue);
|
|
|
|
bool EvalBooleanExpressionAgainstValue(ExprEvalState *evalState,
|
|
const bson_value_t *queryValue,
|
|
bool shouldRecurseIfArray);
|
|
|
|
bson_value_t EvalExpressionAgainstArrayGetFirstMatch(ExprEvalState *evalState,
|
|
const bson_value_t *queryValue);
|
|
List * EvalExpressionAgainstArrayGetAllMatchingIndices(ExprEvalState *evalState,
|
|
const bson_value_t *arrayValue,
|
|
const bool shouldRecurseIfArray);
|
|
|
|
#endif
|