Storage Engine API
mongo::index_key_validate Namespace Reference

Typedefs

using IndexVersion = IndexDescriptor::IndexVersion
 

Functions

Status validateKeyPattern (const BSONObj &key, IndexDescriptor::IndexVersion indexVersion)
 Checks if the key is valid for building an index according to the validation rules for the given index version. More...
 
StatusWith< BSONObj > validateIndexSpec (OperationContext *opCtx, const BSONObj &indexSpec, const NamespaceString &expectedNamespace, const ServerGlobalParams::FeatureCompatibility &featureCompatibility)
 Validates the index specification 'indexSpec' and returns an equivalent index specification that has any missing attributes filled in. More...
 
Status validateIdIndexSpec (const BSONObj &indexSpec)
 Performs additional validation for _id index specifications. More...
 
Status validateIndexSpecFieldNames (const BSONObj &indexSpec)
 Top-level index spec field names are validated here. More...
 
StatusWith< BSONObj > validateIndexSpecCollation (OperationContext *opCtx, const BSONObj &indexSpec, const CollatorInterface *defaultCollator)
 Validates the 'collation' field in the index specification 'indexSpec' and fills in the full collation spec. More...
 

Typedef Documentation

◆ IndexVersion

using mongo::index_key_validate::IndexVersion = typedef IndexDescriptor::IndexVersion

Function Documentation

◆ validateIdIndexSpec()

Status mongo::index_key_validate::validateIdIndexSpec ( const BSONObj &  indexSpec)

Performs additional validation for _id index specifications.

This should be called after validateIndexSpec().

◆ validateIndexSpec()

StatusWith< BSONObj > mongo::index_key_validate::validateIndexSpec ( OperationContext *  opCtx,
const BSONObj &  indexSpec,
const NamespaceString &  expectedNamespace,
const ServerGlobalParams::FeatureCompatibility &  featureCompatibility 
)

Validates the index specification 'indexSpec' and returns an equivalent index specification that has any missing attributes filled in.

If the index specification is malformed, then an error status is returned.

◆ validateIndexSpecCollation()

StatusWith< BSONObj > mongo::index_key_validate::validateIndexSpecCollation ( OperationContext *  opCtx,
const BSONObj &  indexSpec,
const CollatorInterface *  defaultCollator 
)

Validates the 'collation' field in the index specification 'indexSpec' and fills in the full collation spec.

If 'collation' is missing, fills it in with the spec for 'defaultCollator'. Returns the index specification with 'collation' filled in.

◆ validateIndexSpecFieldNames()

Status mongo::index_key_validate::validateIndexSpecFieldNames ( const BSONObj &  indexSpec)

Top-level index spec field names are validated here.

Confirms that 'indexSpec' contains only valid field names.

When adding a new field with a document as value, is the the sub-module's responsibility to ensure that the content is valid and that only expected fields are present at creation time

Returns an error if an unexpected field name is found.

◆ validateKeyPattern()

Status mongo::index_key_validate::validateKeyPattern ( const BSONObj &  key,
IndexDescriptor::IndexVersion  indexVersion 
)

Checks if the key is valid for building an index according to the validation rules for the given index version.