[1.7.x] Fixed #22975: Don't call rename SQL if not needed