Re: Trying to add a type modifier to user created type

From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: Carsten Kropf <ckropf2(at)fh-hof(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trying to add a type modifier to user created type
Date: 2010-02-18 09:16:37
Message-ID: 4B7D0575.7080607@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carsten Kropf wrote:
> Hi *,
> I have the following problem:
> I wanted to add a new type that supports modifiers (comparable to numeric/varchar). I succeeded in adding the type modifier functions to my new type. These methods are called and the modifier is set. However the modifiers are not applied here. I don't know exactly how to get the modifiers to be applied to my type. I looked into the source code of varchar/numeric and a function called the same name as the type is added in there that gets called with a value of the particular type and the typmod, respectively. But I don't know, how to register this function properly in order to get called, when sth is to be stored in the database.
> column. How can I achieve this/What do I have to do to get it to work?
>

It's been a while but I still remember exactly the same question
(frustration?) from some while ago (maybe it is something for the docs)

You need to add a cast from the type to itself, e.g.

-- typmod coercion
CREATE CAST (complex AS complex)
WITH FUNCTION complextypmod(complex,int4)
AS IMPLICIT;

Where complextypemod would be the typmod apply functions (int4 is the
typmod)

Regards,
Yeb Havinga

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2010-02-18 09:25:46 Re: One solution for Packages in Postgre
Previous Message Greg Smith 2010-02-18 09:04:47 Re: about effective_cache_size