No judge shall be competent to testify in any criminal or civil proceeding as to any matter which came before him in the course of his official duties.
Except as otherwise provided in this section, no clerk of any court, magistrate, or other person having the power to issue warrants, shall be competent to testify in any criminal or civil proceeding as to any matter which came before him in the course of his official duties. Such person shall be competent to testify in any criminal proceeding wherein the defendant is charged with perjury or pursuant to the provisions of § 18.2-460 or in any proceeding authorized pursuant to § 19.2-353.3. Notwithstanding any other provision of this section, any judge, clerk of any court, magistrate, or other person having the power to issue warrants, who is the victim of a crime, shall not be incompetent solely because of his office to testify in any criminal or civil proceeding arising out of the crime.
Va. Code § 19.2-271