Update MySQL functions and the _local CSV writing to match