After staring at this for awhile, I've made some changes in
SetClientEncoding to clean up corner cases (it wasn't honoring DoIt in
all cases, and not being completely consistent about when to set
need_to_init_client_encoding either). I am not sure whether this
solves your problem or not, though --- would you check?
Also, I think that the src/test/mb failures are unrelated. Perhaps we
just need to update the expected results there? Or are there real
problems?
regards, tom lane