Fix quoting of tids for COPY

Add a regression test exposing the same.