Re: Change in casting behavior? - Mailing list pgsql-hackers

From Thomas Swan
Subject Re: Change in casting behavior?
Date
Msg-id 3C6DE1B6.4040505@olemiss.edu
Whole thread Raw
In response to Re: Change in casting behavior?  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Change in casting behavior?  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut wrote:<br /><blockquote cite="midPine.LNX.4.30.0202152033550.681-100000@peter.localdomain"
type="cite"><prewrap="">Thomas Swan writes:<br /><br /></pre><blockquote type="cite"><pre wrap="">select (random(
)*10)::varchar(4)<br/>worked in 7.1.3<br /><br />fails in 7.2<br /><br />ERROR:  value too long for type character
varying(4)<br/></pre></blockquote><pre wrap=""><br />Say what you really mean:<br /><br />select substring(random()*10
for4);<br /><br /></pre></blockquote> That may be the better way to say it.  But, what I wanted to point out was that
thebehavior had changed.   Previously ::varchar(4) had worked. However, now since 7.2 only ::text or varchar(n) where
issufficiently large to hold the digits.<br /><br /> As far as I was aware the correct behavior was to truncate the
textrepresentation to fit the field size or the 'casted' size.<br /><br /> I simply thought I would mention as it
caughtme by surpris.<br /><br /> Thomas<br /><br /> 

pgsql-hackers by date:

Previous
From: "Matthew T. O'Connor"
Date:
Subject: Re: changing the nulability of columns
Next
From: Peter Eisentraut
Date:
Subject: Re: Change in casting behavior?