A person committed to prison for any criminal offense who is in the custody of an officer shall not be removed from the prison or delivered to the custody of any other officer, except in the following cases:
(1) By writ of habeas corpus or some other legal writ or under the guidelines of the Interstate Corrections Compact, § 12-49-101 et seq.;
(2) When he or she may be delivered to an officer, to be removed to some common jail;
(3) In case of fire, infectious disease, or other great necessity; or
(4)
(A) When the prisoner is charged by affidavit with treason or felony committed in some other state or territory of the United States of America.
(B) In such a case, on the demand of the executive of that state or the governor of a territory of the United States from which the prisoner fled, the prisoner shall be sent in custody by order of any circuit court or may be bound by recognizance, with good security by the court to appear at the proper time and place and surrender himself or herself to the court or tribunal having jurisdiction of the offense if the court, upon consideration of the evidence, shall be of the opinion that he or she should be put upon trial.