
select (random( )*10)::varchar(4)
worked in 7.1.3

fails in 7.2

ERROR:  value too long for type character varying(4)


Fri, 15 Feb 2002 18:49:33 -0600
Thomas Swan <tswan-lst@ics.olemiss.edu>
Change in casting behavior?
Thomas Swan writes:

> select (random( )*10)::varchar(4)
> worked in 7.1.3
>
> fails in 7.2
>
> ERROR:  value too long for type character varying(4)

Say what you really mean:

select substring(random()*10 for 4);

-- 
Peter Eisentraut   peter_e@gmx.net


Fri, 15 Feb 2002 20:35:49 -0500 (EST)
Peter Eisentraut <peter_e@gmx.net>
Re: Change in casting behavior?





Peter Eisentraut wrote:

Thomas Swan writes:

select (random( )*10)::varchar(4)worked in 7.1.3fails in 7.2ERROR:  value too long for type character varying(4)

Say what you really mean:select substring(random()*10 for 4);

That may be the better way to say it.  But, what I wanted to point out was
that the behavior  had changed.   Previously ::varchar(4) had worked. However,
now since 7.2 only ::text or varchar(n) where is sufficiently large to hold
the digits.

As far as I was aware the correct behavior was to truncate the text representation
to fit the field size or the 'casted' size.

I simply thought I would mention as it caught me by surpris.

Thomas




Fri, 15 Feb 2002 22:36:06 -0600
Thomas Swan <tswan@olemiss.edu>
Re: Change in casting behavior?
Thomas Swan writes:

> As far as I was aware the correct behavior was to truncate the text representation to fit the
> field size or the 'casted' size.

The correct behaviour has been made even more correct in the 7.2 release.
;-)

> I simply thought I would mention as it caught me by surpris.

Should have read the release notes.

-- 
Peter Eisentraut   peter_e@gmx.net


Sat, 16 Feb 2002 00:04:48 -0500 (EST)
Peter Eisentraut <peter_e@gmx.net>
Re: Change in casting behavior?