code: func (d *Accessor) UpsertOCSP(serial, aki, body string, expiry time.Time) error {
  	err := d.checkDB()
  	if err != nil {
  		return err
  	}
  
  	result, err := d.db.NamedExec(updateOCSPSQL, &certdb.OCSPRecord{
  		AKI:    aki,
  		Body:   body,
  		Expiry: expiry.UTC(),
  		Serial: serial,
  	})
  
  	if err != nil {
  		return wrapSQLError(err)
  	}
  
  	numRowsAffected, err := result.RowsAffected()
  
  	if numRowsAffected == 0 {
  		return d.InsertOCSP(certdb.OCSPRecord{Serial: serial, AKI: aki, Body: body, Expiry: expiry})
  	}
  
  	if numRowsAffected != 1 {
  		return wrapSQLError(fmt.Errorf("%d rows are affected, should be 1 row", numRowsAffected))
  	}
  
  	return err
  }
docs: // UpsertOCSP update a ocsp response record with a given serial number,
  // or insert the record if it doesn't yet exist in the db
  // Implementation note:
  // We didn't implement 'upsert' with SQL statement and we lost race condition
  // prevention provided by underlying DBMS.
  // Reasoning:
  // 1. it's diffcult to support multiple DBMS backends in the same time, the
  // SQL syntax differs from one to another.
  // 2. we don't need a strict simultaneous consistency between OCSP and certificate
  // status. It's OK that a OCSP response still shows 'good' while the
  // corresponding certificate is being revoked seconds ago, as long as the OCSP
  // response catches up to be eventually consistent (within hours to days).
  // Write race condition between OCSP writers on OCSP table is not a problem,
  // since we don't have write race condition on Certificate table and OCSP
  // writers should periodically use Certificate table to update OCSP table
  // to catch up.