Re: CAST ON NEW TYPE

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: pejac(at)altern(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CAST ON NEW TYPE
Date: 2000-12-06 15:55:03
Message-ID: 3A2E6157.5EAFDD6D@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-06 16:15:26 Re: AW: beta testing version
Previous Message Tom Lane 2000-12-06 15:34:04 Re: CAST ON NEW TYPE