define type_transform to new user defined type

Started by Mohsen SMalmost 12 years ago3 messages
#1Mohsen 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?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mohsen SM (#1)
Re: define type_transform to new user defined type

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Kyotaro HORIGUCHI
horiguchi.kyotaro@lab.ntt.co.jp
In reply to: Tom Lane (#2)
Re: define type_transform to new user defined type

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers