<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
the negative integers have the first bit 1 in the 32bit
representation of a signed integer. So practically 2^31 (2 147 483
648) to 2^32 - 1 (
<meta charset="utf-8">
4 294 967 296 - 1) are the negative integers, which for unsigned int
representation are the higher values. As the other Daniel said,
those numbers are converted to negative value as: N - 2^32 (where N
is the number greater than 2^31).<br>
<br>
For your case, the best is to use mysql cast function in
sql_pvquery() and get it as string inside kamailio.cfg, no matter
what is the type of the column in the database table. See
cast/convert operators/functions in the mysql manual.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<div class="moz-cite-prefix">On 06/01/16 11:48, Jonathan Hunter
wrote:<br>
</div>
<blockquote cite="mid:DUB112-W104F78088BA992DD822D99DBDF40@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">Hi to both Daniels and thank you for your
responses.
<div><br>
</div>
<div>I understand what you are both saying.</div>
<div><br>
</div>
<div>Currently the field I am extracting the value from in the
database is set to type;</div>
<div><br>
</div>
<div>bigint(20) unsigned </div>
<div><br>
</div>
<div>If I change to varchar for example it returns fine, my only
issue is that the overflow only occurs on 10 digit numbers
starting with 2 or 3.</div>
<div><br>
</div>
<div>If I add a value for example 1785702370 or 7785702370 they
are returned without issue without changing the DB value type.</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div>Jon<br>
<br>
<div>> To: <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
> From: <a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a><br>
> Date: Tue, 5 Jan 2016 19:49:02 +0100<br>
> Subject: Re: [SR-Users] Negative value returned when
using sql_pvquery<br>
> <br>
> <br>
> <br>
> On 05/01/16 17:51, Daniel Tryba wrote:<br>
> > On Tue, Jan 05, 2016 at 03:38:58PM +0000, Jonathan
Hunter wrote:<br>
> >> sql_pvquery("cd","select
DestinationMsisdn,SourceMsisdn from MsisdnPoolAllocations
where
PoolMsisdn='$rU'","$var(MOdest),$var(NewSourceMSISDN)");<br>
> >> However this returns a value of -509264926 for
$var(MOdest) which should just be the 3785702370 number.<br>
> >> What can cause kamailio to interpret this as a
negative value? Has anyone seen this before?<br>
> > What you are seeing is an integer overflow, in
this case you are trying<br>
> > to store a number greater than 2^31 in a signed
32bit int. -509264926<br>
> > (3785702370-2^32) is the correct answer if the var
is a signed 32bit<br>
> > int.<br>
> ><br>
> > I treat phonenumbers as strings (both in the
database and kamailio)<br>
> > since I store them as E.164 with a leading +
(which results in a bit<br>
> > more diskspace)<br>
> ><br>
> > If you don't need the number as int in kamailio,
try casting it to a<br>
> > string in the query.<br>
> ><br>
> To complete, as just looked at the source -- if the
bigint number<br>
> returned does not fit in 32bit size, then it is stored
as string. If it<br>
> fits in 32bit, then is stored also as int. I see the
code was added in<br>
> 2011 by Alex Hermann.<br>
> <br>
> Maybe the behavior is not that coherent, hard to
predict if not knowing<br>
> what is in the db, and should be changed to be always
stored as string,<br>
> then use {s.int} in config if wanted as int.<br>
> <br>
> Cheers,<br>
> Daniel<br>
> <br>
> -- <br>
> Daniel-Constantin Mierla<br>
> <a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> -
<a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a><br>
> Book: SIP Routing With Kamailio - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a><br>
> <a class="moz-txt-link-freetext" href="http://miconda.eu">http://miconda.eu</a><br>
> <br>
> <br>
> _______________________________________________<br>
> SIP Express Router (SER) and Kamailio (OpenSER) -
sr-users mailing list<br>
> <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div>
</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://miconda.eu">http://miconda.eu</a></pre>
</body>
</html>