Re: Importing data w/ Unix timestamp

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Importing data w/ Unix timestamp
Дата
Msg-id 1155.962305441@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Importing data w/ Unix timestamp  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mitch Vincent"
Дата:
Сообщение: Trigger question.. (Heaptuple struct)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump/load quoting.