define type_transform to new user defined type

Поиск
Список
Период
Сортировка
Искать

define type_transform to new user defined type

От:
Mohsen SM <mohsensoodkhah@gmail.com>
Дата:
 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?

Re: define type_transform to new user defined type

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Mohsen SM  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

От:
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Дата:
Hello,

> Mohsen SM  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


FAQ