<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
IC 5.7.2, Postgres 8.3<br>
<br>
In Table::DBI.pm the MAX_FIELD_LENGTH for each element in a table in a
Postgres database is discovered with<br>
<br>
SELECT a.attnum,t.typname,a.attlen,a.atttypmod,a.attname FROM pg_class
c,pg_attribute a,pg_type t WHERE c.relname='_TABLE_' AND a.attnum &gt;
0 AND a.attrelid = c.oid AND a.atttypid = t.oid ORDER BY a.attnum;<br>
<br>
at line 225. In the case of a field with type bigint or int8, the
attlen returned is 8, which is quite correct. That indicates that the
maximum value is 8 bytes of storage, a maximum value of 2^63, or
9223372036854775807. That's great! <br>
<br>
On the other hand, down at the if statement at line 757, namely:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( $stype=~/numeric/i&nbsp; or $stype=~/varbit/i ){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scfg-&gt;{LENGTH} = $slenvar;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scfg-&gt;{LENGTH} = $len;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
IC decides that the length of the bigint can't be more than 8 digits,
which yields a maximum value of 99999999, which as you can see yields a
much lower maximum than 9223372036854775807.<br>
<br>
Trying to write a slice containing a bigint &gt; 99999999 yields an
error:<br>
<span style="color: green;">
<li>Vend::Table::DBI - Length Exception! - Data length: 9 Field length:
8 </li>
<li>Vend::Table::DBI - Length Exception - Table: userdb, Field:
&lt;field name&gt;. Action to take: truncate_log </li>
</span>which then proceeds to lop the final digit off the bigint and
stores it. For example, if you try to write 123456789, IC will produce
this error and actually write 12345678 instead.<br>
See how that could be a problem?<br>
<br>
Since this was a rather critical error for us, I applied the simplest
possible hack just to stop the bleeding, namely to insert<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif ($stype =~/int8/i) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scfg-&gt;{LENGTH} = 19;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
into the above the above if statement. I suppose a better approach
would have to be do something like<br>
&nbsp;&nbsp; elsif($ctype =~ /^int/i) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scfg-&gt;{LENGTH} = length(2 ** (($len * 8)-1));<br>
&nbsp;&nbsp; }<br>
<br>
But either way it's a significant problem and I just wanted to point it
out so it can be fixed for future releases.<br>
<br>
Chris.<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>