Complete spatial and temporal locking in phase-mismatched second-harmonic generation