[OpenSIPS-Users] MySQL Type: FIELD_TYPE_NEWDECIMAL (246) uses DB_INT result type but should use float
Brett Nemeroff
brett at nemeroff.com
Mon Mar 9 22:36:25 EST 2020
Calvin,
If you look at the code blocks, I’d start by mirroring one of the string
type conversion code blocks and see how you do. You should see it repeated
a bunch of times (in avpops_db.c). I’m away from the code right now, so I
can only be of limited help at the moment.
-Brett
On Mon, Mar 9, 2020 at 5:25 PM Calvin Ellison <calvin.ellison at voxox.com>
wrote:
> Copying Brett's reply back to the list. I deleted some of the previous
> conversation to avoid "message too large".
>
> I also noticed DB_DOUBLE is missing from /avpops/avpops_db.c but I don't
> know C well enough to do the needful. Do you know what should be done to
> make it a string?
>
> Here's my updated /db_mysql/res.c. I did as you suggested and
> moved MYSQL_TYPE_NEWDECIMAL along with its #if condition to just after
> MYSQL_TYPE_FLOAT so it is DB_DOUBLE not DB_INT. It looks like the same
> change is needed for MYSQL_TYPE_DECIMAL since this can also be non-integer,
> but I didn't touch that.
>
> switch(fields[col].type) {
> case MYSQL_TYPE_TINY:
> case MYSQL_TYPE_SHORT:
> case MYSQL_TYPE_LONG:
> case MYSQL_TYPE_INT24:
> case MYSQL_TYPE_DECIMAL:
> case MYSQL_TYPE_TIMESTAMP:
> LM_DBG("use DB_INT result type\n");
> RES_TYPES(_r)[col] = DB_INT;
> break;
>
> case MYSQL_TYPE_FLOAT:
> #if MYSQL_VERSION_ID > 49999
> case MYSQL_TYPE_NEWDECIMAL:
> #endif
> case MYSQL_TYPE_DOUBLE:
> LM_DBG("use DB_DOUBLE result type\n");
> RES_TYPES(_r)[col] = DB_DOUBLE;
> break;
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200309/69e6c142/attachment-0001.html>
More information about the Users
mailing list