Skip to content

bigint error #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
k3win opened this issue Mar 17, 2016 · 8 comments
Closed

bigint error #1371

k3win opened this issue Mar 17, 2016 · 8 comments
Assignees

Comments

@k3win
Copy link

k3win commented Mar 17, 2016

today, I found an error at bigint parsing.
query result:

[ RowDataPacket { trace_id: -185395119379775650, a_timestamp: 1457687553183000 },
  RowDataPacket {
    trace_id: '5083290603631050820',
    a_timestamp: 1457687168117000 },
  RowDataPacket {
    trace_id: '4376063674742127992',
    a_timestamp: 1457686343709000 }]

i found that the negative bigint would not been parsed into String and overflowed, and i have set the 'supportBigNumbers' on true
it used to be -185395119379775634

@dougwilson
Copy link
Member

Hi @k3win, thanks for the report! In order to help get this going, can you please provide all the following information?

  1. Version of Node.js
  2. Version of this module
  3. Version of MySQL server
  4. DDL I can use to create a sample table
  5. SQL I can use to insert sample data into the table
  6. Node.js code using this library to select from that table that will demonstrate this issue

Thank you!

@dougwilson
Copy link
Member

Hi @k3win can you please provide the above information?

@k3win
Copy link
Author

k3win commented Mar 28, 2016

1.node -v
v5.3.0
2.node-mysql version
"version": "0.4.2"
3.mysql version
mysql Ver 14.14 Distrib 5.5.44, for debian-linux-gnu (x86_64)
4.ddl

create table test(
    id int(10) primary key AUTO_INCREMENT,
    big bigint
)

5.conf

var config = {
    db:{
        connectionLimit : 10,
        host            : '172.16.30.149',
        user            : 'root',
        password        : 'password',
        database        : 'kdTestDb',
        supportBigNumbers: true
    }
}

6.query

SELECT * FROM test

7.results

[{"id":1,"big":"9223372036854775807"},{"id":2,"big":-9223372036854776000},{"id":3,"big":"1111111111111111111"},{"id":4,"big":-1111111111111111200}]

it seems that nodejs do not support the bigint and make it overflow. @dougwilson

@dougwilson
Copy link
Member

Hi @k3win thanks for the information! Yes, JavaScript does not support them, but we provide some layers to help with that. The main thing I noticed from your report there is you are using a different module. The version 0.4.2 corresponds to a different module: https://www.npmjs.com/package/node-mysql

This module is just called "mysql" and the current version is 2.10.2. If you are using that other module, you may want to open a bug on their issue tracker: https://github.com/redblaze/node-mysql/issues

@k3win
Copy link
Author

k3win commented Mar 28, 2016

this time i use "version": "2.10.2", but it's still wrong..@dougwilson

@dougwilson
Copy link
Member

Thanks for the update, @k3win ! It looks like you missed some of the things I needed to investigate. Please provide items 5 and 6. The two things you marked as 5 and 6 in your reply are not correct. For item 5 I need the SQL I can use to actually insert the data into the table. By default, the table is empty, so I have nothing to select when I try your query. For item 6, I need the complete code, including things like the require statement, the createConnection statement, etc. It should be such that I can actually copy and paste into a file to run.

@dougwilson dougwilson reopened this Mar 28, 2016
@k3win
Copy link
Author

k3win commented Mar 28, 2016

4:

use kdTestDb;
create table test(
    id int(10) primary key AUTO_INCREMENT,
    big bigint
);
insert into test(big) values(11111111111111111111);
insert into test(big) values(-11111111111111111111);

5:

var config = {
    db:{
        connectionLimit : 10,
        host            : '172.16.30.149',
        user            : 'root',
        password        : 'password',
        database        : 'kdTestDb',
        supportBigNumbers: true
    }
}
module.exports = config;

6:

var express = require('express');
var app = express();

var mysql = require('mysql');
var conf = require('./config');
var pool = mysql.createPool(conf.db);
pool.on('connection', function (connection) {
    var conf = connection.config;
    console.log("connected db:"+conf.host+":"+conf.port + " success");
});

app.get("/",function(req,res,next){
    pool.getConnection(function(err,conn){
        if(err)
            res.sendStatus(500);
        else{
            conn.query("SELECT * FROM test", function(err,rows){

                res.send(rows);
                conn.release();
            });
        }
    });
});
app.listen(4000, function () {
});

@dougwilson

Dinwy added a commit to Dinwy/node-mysql that referenced this issue Mar 30, 2016
mysqljs#1371 Fix bigint out of range problem
@k3win
Copy link
Author

k3win commented Mar 31, 2016

@dougwilson Thank for support, I make a mistake that I forget to write bigNumberStrings: true.

@k3win k3win closed this as completed Mar 31, 2016
Dinwy added a commit to Dinwy/node-mysql that referenced this issue Apr 6, 2016
Dinwy added a commit to Dinwy/node-mysql that referenced this issue Apr 6, 2016
Dinwy added a commit to Dinwy/node-mysql that referenced this issue Apr 6, 2016
Dinwy added a commit to Dinwy/node-mysql that referenced this issue Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants