> I create a new type that work well, but when
> i use the cast function on my new type like this i have an error:
> (other fucntion like substring don't work too )
> select bare_code::text from ean_article;
> ERROR: Cannot cast type 'ean13' to 'text'
> What can i do in my new type in order to use cast ???
You need to define one more function as text(ean13), which PostgreSQL
will assume is intended for casting. The actual implementation will be
called something different, say ean13_text(), so that the entry point is
unique, and then you will define it as text(ean13) in the pg_proc
catalog or the CREATE FUNCTION statement. There are examples of how to
do the actual code in the utils/adt directory for other types; I was
looking at the code for timestamp->text the other day.
Good luck.
- Thomas