Teradata support

As per overview in #304 to resolve #168 and #7.
That's exactly my point - the massive whitespace reformatting is making very hard to see the other changes.