private void createRoutineCommon(Session session, Routine routine,
boolean inSystem, boolean replaceExisting) {
final AkibanInformationSchema oldAIS = getAISForChange(session, !inSystem);
checkSystemSchema(routine.getName(), inSystem);
if (!replaceExisting && (oldAIS.getRoutine(routine.getName()) != null))
throw new DuplicateRoutineNameException(routine.getName());
// This may not be the generation that newAIS will receive,
// but it will still be > than any previous routine, and in
// particular any by the same name, whether replaced here or
// dropped earlier.
routine.setVersion(oldAIS.getGeneration() + 1);