Re: create type- similar char

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mohsen SM <mohsensoodkhah(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: create type- similar char
Date: 2014-03-16 15:39:24
Message-ID: 25904.1394984364@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mohsen SM <mohsensoodkhah(at)gmail(dot)com> writes:
> I create one new type with CREATE TYPE command.
> for my type its INTERNALLENGTH is VARIABLE .
> but I want to my type behavior similar to char and when I type this query:
> CREATE TABLE tbl (col1 NEWTYPE);
> then when I write this query, so it get an error for it's length:
> insert into tbl values('dd');
> its error is :
> ERROR: value too long for type character(1)
> but my NEWTYPE don't get this error and work similar to varchar.
> how I can do it?
> I check for char type the bpchar() function. when I work with char type and
> want to insert one word longest one character so, bpchar() called.
> but for my NEWTYPE don't call the newtype() function.

It sounds like you made a length coercion cast function, but didn't
actually declare a cast based on it. See CREATE CAST.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-03-16 15:46:43 Re: Minimum supported version of Python?
Previous Message Tom Lane 2014-03-16 15:26:16 Re: Portability issues in shm_mq