Thread: when are the xxxin() functions called

when are the xxxin() functions called

From
Rui Hai Jiang
Date:
Hello,

I'm trying to figure out when the following functions are called,

charin()
int2in()
int4in()
textin()


I used GDB for debuging. I set break points at each function and I did 
following testing.
  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?

Thanks,

Rui Hai



Re: when are the xxxin() functions called

From
Amit Langote
Date:
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




Re: when are the xxxin() functions called

From
Michael Paquier
Date:
On Thu, May 7, 2015 at 11:49 PM, Rui Hai Jiang <ruihaijiang@msn.com> wrote:
> Does anyone know when are charin(),int2in() and int4in() called?

Those are input functions for respectively the types char, smallint
and int. Look at the docs here for more details:
http://www.postgresql.org/docs/devel/static/sql-createtype.html
"The input_function converts the type's external textual
representation to the internal representation used by the operators
and functions defined for the type."
Regards,
-- 
Michael