[SERVER-73834] NamespaceString constants: immortality and constexprness Created: 09/Feb/23  Updated: 29/Oct/23  Resolved: 10/Feb/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-73112 Move NamespaceString constructors pri... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2023-02-20
Participants:

 Description   

NamespaceString cannot be constexpr, but it defines several dozen k-constants for reserved namespace values. These are not 100% init-safe, as they have static nonlocal storage duration and can be accessed when they aren't ready by the initializers of other TUs in the system.

This can be worked around by changing the types of these constants to something that basically works like a NamespaceString, and is implicitly convertible to NamespaceString, but executes some memoizing instantiation code upon use.

This requires either repeating the huge and growing list of identifiers a few times, or simply moving the constant definitions into an x-macro definition table that can be expanded multiple times. The latter is much better, and has the side benefit of reducing code churn and interface bloat in the namespace_string component's source code.



 Comments   
Comment by Githook User [ 10/Feb/23 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-73834 NamespaceString constants immortal and constexpr
Branch: master
https://github.com/mongodb/mongo/commit/332a6b7c11d58b5d9e2582bff0b2555a46ee556e

Generated at Thu Feb 08 06:25:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.