Re: CAST function for user defined type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CAST function for user defined type
Date: 2007-01-22 16:40:08
Message-ID: 25105.1169484008@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com> writes:
> That cleared one hurdle, but I'm still not there yet.

> % select 'fe43d07c0c624786bebfcb3357a2a13a'::y_octet_16;
> y_octet_16
> ----------------------------------
> fe43d07c0c624786bebfcb3357a2a13a

That's not invoking any cast function, but the type's typinput function
(applied to a C-string).

> When things are connected up this way,
> what should the cast function expect to see as input?

> % select encode( y_uuid_generate(), 'hex' )::y_octet_16;
> ERROR: input string contains invalid characters

If it's a cast from TEXT, it'll get the internal form of a TEXT datum,
ie, a counted (and not null-terminated) string. You might look at
textin() and textout() to grok the difference.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-01-22 16:44:08 Tracking database activity
Previous Message Peter Rosenthal 2007-01-22 16:32:20 Re: MSSQL/ASP migration