Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-75733

Clarify lifetime guarantees of NamespaceString::ns and DatabaseName::db

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 7.1.0-rc0, 7.0.0-rc1
    • None
    • None
    • None
    • Fully Compatible
    • v7.0
    • Server Serverless 2023-04-17

    Description

      NamespaceString::ns and DatabaseName::db both return const std::string& to their own std::string storage. This leads to difficult-to-maintain code because the lifetime of the returned value is unclear: sometimes it results in a copy, other times it remains a const-ref.

      With the upcoming changes in SERVER-75529, we no longer have the option of returning a const-ref to a member variable. Having these methods return std::string violates assumptions of some call sites due to the aforementioned lifetime ambiguity. This ticket is a pre-requisite, it will change these methods to return a StringData which will a) clarify the lifetime assumptions at the callsite, b) ease the transition to the changes proposed in SERVER-75529.

      Attachments

        Activity

          People

            matt.broadstone@mongodb.com Matt Broadstone
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: