|
Except for a few odd ducks like the group command (which was deprecated in 3.4.0), commands have three styles in which they accept namespace strings:
- The command takes the collection name as its first parameter. This is true of commands like find and aggregate. This this case, the fully-qualified namespace string is computed by combining the database string against which the command was run with the collection string extracted from the command parameters. This process is implemented by Command::parseNsCollectionRequired().
- The command takes a fully-qualified namespace as its first parameter. This is true of commands like shardCollection and moveChunk. Parsing of such namespace strings is handled by Command::parseNsFullyQualified().
- The command does not include a namespace in its parameters, and instead we just use the database name. In this case, we shouldn't need any parsing function, since there is no additional command parsing to do.
Based on this analysis, I think most uses of Command::parseNs() are probably subtly wrong. We are planning to fix a lot of these problems in SERVER-24128, which I have linked as related. Rather than fix Command::parseNs(), it might be better to delete it altogether and to migrate callers to more appropriate parsing functions.
|