On 2015-05-07 PM 11:49, Rui Hai Jiang wrote:
>
> I'm trying to figure out when the following functions are called,
>
> charin()
> int2in()
> int4in()
> textin()
>
> create table abcin( id integer, name varchar(10), title text);
> insert into abcin( id, name, title ) values (1,'tom', 'manager');
>
> The result is, textin() was called to handle 'manager' assigned to title, but
> charin(), int2in and int4in were not called.
>
> Does anyone know when are charin(),int2in() and int4in() called?
>
During parsing of the insert query, the values list (1,'tom', 'manager') is
transformed into an internal form during which it is determined that the first
value in the list can be represented as a machine integer - so it is evaluated
and stored for direct use later. Other literal values do not have such a
direct machine representation and require treatment (coercion to the target
type) using the input functions in later stages of query processing. By the
way, for the 'name' field, varcharin() would be used (not charin).
Thanks,
Amit