Dennis Björklund <db@zigo.dhs.org> writes:
> It seems to me that one would like to have a polymorphic typesystem with
> constraints to handle overloading, subtyping or whatever is needed in
> SQL.
What we have now is indeed pretty ad-hoc, but a full-blown type
inference system might be overkill. Not sure. It would be interesting
to look into it.
> Is there anywhere I can read about the typesystem in SQL in general and
> postgresql in particular?
There's the user's guide
http://developer.postgresql.org/docs/postgres/typeconv.html
and there's the source code (see src/backend/parser/, particularly
parse_coerce.c, parse_func.c, parse_oper.c). Not much in between
I'm afraid, but the source code is reasonably well-commented.
regards, tom lane