[SERVER-51266] Add support for BSONType::RegEx in SBE Created: 01/Oct/20  Updated: 29/Oct/23  Resolved: 11/Feb/21

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Task Priority: Major - P3
Reporter: Anton Korshunov Assignee: Nikita Lapkov (Inactive)
Resolution: Fixed Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes SERVER-55180 Remove StringData <=> std::string_vie... Closed
Related
related to SERVER-54319 [SBE] Different error code is returne... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2020-12-14, Query 2020-12-28, Query 2021-01-11, Query 2021-01-25, Query Execution 2021-02-22
Participants:

 Description   

Once it's done, the implementation of regexp agg expressions in SBE delivered via SERVER-50734 should also be updated to support the new type.



 Comments   
Comment by Githook User [ 11/Feb/21 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-51266 Add BSONType::RegEx support in SBE. Fix $regex aggregation expressions error handling
Branch: master
https://github.com/mongodb/mongo/commit/6d419110f2dbd9b07ee96a601356ddbe99628dc5

Comment by Nikita Lapkov (Inactive) [ 28/Jan/21 ]

I have studied the behaviour Regex expression in the classic engine. They check the following conditions and raise errors if they are not true:

  1. Regex pattern is a string, BSONRegEx or null
  2. Regex flags is string or null
  3. If regex has BSONRegEx type and options field in the query is defined, only one of them can be non-empty
  4. Regex pattern cannot contain null bytes
  5. Regex flags cannot contain null bytes (even if regex pattern is null)
  6. Regex pattern must be valid
  7. Regex flags must be valid

Condition 1 is checked in the SBE tree. If condition 7 is false, there is an assert in VM. Condition 3 is not checked since we do not have BSONRegEx support in SBE yet.

We do not raise an error if conditions 2, 4, 5 or 6 are false. This can be seen only when regex pattern or flags are not constant expressions. When they are constant expressions, these conditions are checked in optimize method of respective expressions.

Also, during the SBE regex expressions building we use getConstantPatternAndOptions method to check some of these conditions. This method is not used in the classic engine and I am not sure it is consistent with classic engine's behaviour.

Generated at Thu Feb 08 05:24:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.