Duncan McEwan <duncan@mcs.vuw.ac.nz> for the hint in PR#15412. I'll leave the rest of his patch for someone more familiar with join to fix.