Re: Change in casting behavior?

From: Thomas Swan <tswan(at)olemiss(dot)edu>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Thomas Swan <tswan-lst(at)ics(dot)olemiss(dot)edu>, Postgresql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Change in casting behavior?
Date: 2002-02-16 04:36:06
Message-ID: 3C6DE1B6.4040505@olemiss.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

<!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(dot)LNX(dot)4(dot)30(dot)0202152033550(dot)681-100000(at)peter(dot)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. &nbsp;But, what I wanted to point out was
that the behavior had changed. &nbsp; 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>

Attachment Content-Type Size
unknown_filename text/html 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2002-02-16 04:56:13 Re: Ready to branch 7.2/7.3 ?
Previous Message Matthew T. O'Connor 2002-02-16 04:35:39 Re: changing the nulability of columns