Thread
-
Change in casting behavior?
Thomas Swan <tswan-lst@ics.olemiss.edu> — 2002-02-16T00:49:33Z
select (random( )*10)::varchar(4) worked in 7.1.3 fails in 7.2 ERROR: value too long for type character varying(4)
-
Re: Change in casting behavior?
Peter Eisentraut <peter_e@gmx.net> — 2002-02-16T01:35:49Z
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
-
Re: Change in casting behavior?
Thomas Swan <tswan@olemiss.edu> — 2002-02-16T04:36:06Z
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> Peter Eisentraut wrote:<br> <blockquote type="cite" cite="midPine.LNX.4.30.0202152033550.681-100000@peter.localdomain"> <pre wrap="">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 for 4);<br><br></pre> </blockquote> 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.<br> <br> As far as I was aware the correct behavior was to truncate the text representation to fit the field size or the 'casted' size.<br> <br> I simply thought I would mention as it caught me by surpris.<br> <br> Thomas<br> <br> </body> </html> -
Re: Change in casting behavior?
Peter Eisentraut <peter_e@gmx.net> — 2002-02-16T05:04:48Z
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