Re: sequences what does ::text mean ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Jore <josh(at)lavendergreens(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: sequences what does ::text mean ?
Date: 2002-07-03 15:20:29
Message-ID: 24970.1025709629@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Josh Jore <josh(at)lavendergreens(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Jore 2002-07-03 17:53:18 Re: sequences what does ::text mean ?
Previous Message Tom Lane 2002-07-03 14:57:03 Re: how to view table foreign keys/triggers?