Thread: define type_transform to new user defined type

define type_transform to new user defined type

From
Mohsen SM
Date:
<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> I want to create new type that
issimilar to varchar.</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">its size is
variable.</div><divstyle="font-family:arial,sans-serif;font-size:12.727272033691406px">I use CREATE TYPE
query.</div><divstyle="font-family:arial,sans-serif;font-size:12.727272033691406px">I define for that type this
functions:</div><divstyle="font-family:arial,sans-serif;font-size:12.727272033691406px"> 1-typein</div><div
style="font-family:arial,sans-serif;font-size:12.727272033691406px">2-typeoute</div><div
style="font-family:arial,sans-serif;font-size:12.727272033691406px">3-typemodify_input</div><div
style="font-family:arial,sans-serif;font-size:12.727272033691406px">4-typemodify_output</div><div
style="font-family:arial,sans-serif;font-size:12.727272033691406px">5-type_transform</div><div
style="font-family:arial,sans-serif;font-size:12.727272033691406px">Ican define 1 to 4 functions in CREATE
TYPE</div><divstyle="font-family:arial,sans-serif;font-size:12.727272033691406px">but I can't define type_transform for
thattype. how did I can define type_transform for that type?</div></div> 

Re: define type_transform to new user defined type

From
Tom Lane
Date:
Mohsen SM <mohsensoodkhah@gmail.com> writes:
>  I want to create new type that is similar to varchar.
> its size is variable.
> I use CREATE TYPE query.
> I define for that type this functions:
> 1-typein
> 2-typeoute
> 3-typemodify_input
> 4-typemodify_output
> 5-type_transform
> I can define 1 to 4 functions in CREATE TYPE
> but I can't define type_transform for that type. how did I can define
> type_transform for that type?

There's no such thing as a "type transform".  There are transforms
associated with functions ... unfortunately, there's not currently
any provision for defining those at the SQL level.  You could poke
an entry into pg_proc.protransform if you're desperate enough.
        regards, tom lane



Re: define type_transform to new user defined type

From
Kyotaro HORIGUCHI
Date:
Hello,

> Mohsen SM <mohsensoodkhah@gmail.com> writes:
>  I want to create new type that is similar to varchar.
> its size is variable.
> I use CREATE TYPE query.
> I define for that type this functions:
> 1-typein
> 2-typeoute
> 3-typemodify_input
> 4-typemodify_output
> 5-type_transform
> I can define 1 to 4 functions in CREATE TYPE
> but I can't define type_transform for that type. how did I can define
> type_transform for that type?

"type cast" came in my mind seeing "type transoform" among
them. You could do that by using 'CREATE CAST' if this is right.

http://www.postgresql.org/docs/current/static/sql-createcast.html

At Tue, 25 Feb 2014 16:11:46 -0500, Tom Lane wrote
> There's no such thing as a "type transform".  There are transforms
> associated with functions ... unfortunately, there's not currently
> any provision for defining those at the SQL level.  You could poke
> an entry into pg_proc.protransform if you're desperate enough.

Just for curiosity but could I have some examples for transforms
associated with functions? I saw a lot of "transform"s for
clauses, exprs, plan nodes, etc, but I had nothing so grepping
src/backend/* for 'transform'.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center