code: func (ssa *SQLStorageAuthority) GetPendingAuthorization(
  	ctx context.Context,
  	req *sapb.GetPendingAuthorizationRequest,
  ) (*core.Authorization, error) {
  	identifierJSON, err := json.Marshal(core.AcmeIdentifier{
  		Type:  core.IdentifierType(*req.IdentifierType),
  		Value: *req.IdentifierValue,
  	})
  	if err != nil {
  		return nil, err
  	}
  
  	// Note: This will use the index on `registrationId`, `expires`, which should
  	// keep the amount of scanning to a minimum. That index does not include the
  	// identifier, so accounts with huge numbers of pending authzs may result in
  	// slow queries here.
  	pa, err := selectPendingAuthz(ssa.dbMap.WithContext(ctx),
  		`WHERE registrationID = :regID
  			 AND identifier = :identifierJSON
  			 AND status = :status
  			 AND expires > :validUntil
  		 ORDER BY expires ASC
  		 LIMIT 1`,
  		map[string]interface{}{
  			"regID":          *req.RegistrationID,
  			"identifierJSON": identifierJSON,
  			"status":         string(core.StatusPending),
  			"validUntil":     time.Unix(0, *req.ValidUntil),
  		})
  	if err == sql.ErrNoRows {
  		return nil, berrors.NotFoundError("pending authz not found")
  	} else if err == nil {
  		// We found an authz, but we still need to fetch its challenges. To
  		// simplify things, just call GetAuthorization, which takes care of that.
  		authz, err := ssa.GetAuthorization(ctx, pa.ID)
  		return &authz, err
  	} else {
  		// Any error other than ErrNoRows; return the error
  		return nil, err
  	}
  
  }
docs: // GetPendingAuthorization returns the most recent Pending authorization
  // with the given identifier, if available.