Re: sequences what does ::text mean ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: sequences what does ::text mean ?
Дата
Msg-id 24970.1025709629@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: sequences what does ::text mean ?  (Josh Jore <josh@lavendergreens.org>)
Ответы Re: sequences what does ::text mean ?  (Josh Jore <josh@lavendergreens.org>)
Список pgsql-novice
Josh Jore <josh@lavendergreens.org> writes:
> My understanding (which was largely
> guessing after watching Josh Berkus) was that the atom 'seq_auteurs' is
> considered to be of unknown type until it is needed for evaluation in an
> expression. During evaluation the value is coerced into something more
> specific. My thought was that if the value is pre-coerced then that saves
> a run-time step.

Actually, either form will produce the exact same run-time behavior:
a literal constant of type TEXT is fed to the function nextval(text),
which returns an int4 (or an int8 on 7.2 and later).

The reason pg_dump emits the ::text cast is that it's being paranoid
about making sure that the reloaded dump will be interpreted exactly
the same way.  For example, if we had both nextval(text) and
nextval(varchar) then an explicit cast would be essential to ensure that
the same one is chosen next time.  (We don't have multiple versions of
nextval, but there are other functions and operators where this exact
scenario arises.  Also, pg_dump is trying to cover its rear in case new
functions get added in future releases, possibly creating a choice of
interpretations where none exists today.)

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: how to view table foreign keys/triggers?
Следующее
От: Henk Schets
Дата:
Сообщение: sequences what does ::text mean ?