-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Replication, Upgrade/Downgrade
-
None
-
Fully Compatible
-
Repl 2020-09-07
I was surprised when
if (const auto& fcv = serverGlobalParams.featureCompatibility; fcv.isVersionInitialized() && fcv.isGreaterThanOrEqualTo(ServerGlobalParams::FeatureCompatibility::Version::kVersion47)) { // ... }
wouldn't compile. So the newly-added accessors (isLessThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isGreaterThan, isUpgradingOrDowngrading) should be const-qualified.
However in addition to this it might be better if serverGlobalParams.featureCompatibility was a const ref, with some other name for the places that legitimately need to modify it, eg.
Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
struct ServerGlobalParams { // ... struct FeatureCompatibility { // ... - } featureCompatibility; + } featureCompatibilityMutable; + const FeatureCompatibility& featureCompatibility = featureCompatibilityMutable; // ... };
This would have caught the missing const-qualifier on the accessors when they were added (in addition to helping prevent accidents).
- related to
-
SERVER-49070 Add FCV gating helpers
- Closed