Re: CAST ON NEW TYPE
От | Thomas Lockhart |
---|---|
Тема | Re: CAST ON NEW TYPE |
Дата | |
Msg-id | 3A2E6157.5EAFDD6D@alumni.caltech.edu обсуждение исходный текст |
Ответ на | CAST ON NEW TYPE (<pejac@altern.org>) |
Список | pgsql-hackers |
> 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
В списке pgsql-hackers по дате отправления: