Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> Another side comment: afaik an explicit conversion to abstime is not
> required to go from Unix time to timestamp. So
> insert into RealTable select uname, timestamp(timeinAsInt4),
> duration, etc from TempTable;
> should be equivalent.
Ah, right, that does work. Just to drift a little further off topic,
the locutions
timeinAsInt4::timestamp
cast (timeinAsInt4 as timestamp)
do not work, because in those cases the parser expects to find a
one-step conversion method, and there isn't one --- at least not in
the standard set of Postgres functions. The function-call syntax works
because there is a function timestamp(abstime) and the parser figures
out it can resolve the ambiguous function name timestamp() as that
function if it first applies int4-to-abstime coercion, which it knows
how to do.
In short: you can get a two-step type conversion from the function call
notation, but only one-step from cast notation.
regards, tom lane