Skip site navigation (1) Skip section navigation (2)

Re: BUG #2490: '||' and type casting for user defined types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nikolay Samokhvalov" <pg-bugs(at)samokhvalov(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2490: '||' and type casting for user defined types
Date: 2006-06-22 17:41:32
Message-ID: 1541.1150998092@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Nikolay Samokhvalov" <pg-bugs(at)samokhvalov(dot)com> writes:
> CREATE CAST (aaa AS text) WITHOUT FUNCTION
> 	AS IMPLICIT;
> CREATE CAST (text AS aaa) WITHOUT FUNCTION
> 	AS IMPLICIT;

> trash=# select ('as' || 'df')::aaa;
>  aaa  
> ------
>  asdf
> (1 row)

> In the last case, function aaa_in() wasn't invoked at all and we obtained 
> the sting of type aaa with length > 3...

Well, sure.  You declared the text to aaa cast as WITHOUT FUNCTION; that
says the system can relabel any legal text value as an aaa.  If you want
to enforce a length limit on the cast result, you need to write a cast
function that does it.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2006-06-22 18:46:56
Subject: Re: BUG #2488: backup history file is archived doubly
Previous:From: Tom LaneDate: 2006-06-22 15:42:47
Subject: Re: BUG #2489: Metadata dosen't match tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group