You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mysql connected
result: { insert_id: undefined,
affected_rows: undefined,
rows:
[ { reason_zero: 4294967296, num: NaN },
{ reason_zero: 25769803777, num: NaN } ] }
If I use the commented-out reason AS reason_zero,, mysql-native works (but that is not the query I need to run).
If I use the commented-out (reason > 0) AS reason_zero,, I get the same failure mode.
I'm using the latest mysql-native (from GitHub). (git pull told me Updating 2b4f1ba..7677112.)
Thanks,
Chris.
P.S. Changing the column types in the database from bigint and smallint to int does not fix the issue.
/* This is a minimal test case for issue https://github.com/sidorares/nodejs-mysql-native/issues/54*/varmy=require("mysql-native");varsql='SELECT '//+ 'reason AS reason_zero, '//+ '(reason > 0) AS reason_zero, ' // FIXME: why doesn't this work?+'LEAST(reason, 1) AS reason_zero, '// FIXME: why doesn't this work?+'COUNT(*) AS num '+'FROM event_bearer_ip '+'GROUP BY reason_zero ';vardb=my.createTCPClient('127.0.0.1',3306);db.auto_prepare=true;vardb_name="test_db";varusername="test_user";varpassword="test_password";db.auth(db_name,username,password);db.addListener('connect',function(){console.info("mysql connected");varquery=db.execute(sql,[]);query.on('result',function(result){console.info("result:",result);process.exit(0);});query.on('error',function(err){console.warn("err:",err);process.exit(1);});});/*-- MySQL dump 10.13 Distrib 5.1.49, for debian-linux-gnu (x86_64)---- Host: localhost Database: test_db-- -------------------------------------------------------- Server version 5.1.49-1ubuntu8.1-log---- Table structure for table `event_bearer_ip`--DROP TABLE IF EXISTS `event_bearer_ip`;CREATE TABLE `event_bearer_ip` ( `id` bigint(20) unsigned NOT NULL, `reason` smallint(5) unsigned DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Bearer used for IP';---- Dumping data for table `event_bearer_ip`--LOCK TABLES `event_bearer_ip` WRITE;INSERT INTO `event_bearer_ip` VALUES (2530,1006),(2834,1006),(37177,1009),(60652,1009),(647439,103),(647650,0),(762547,1008);UNLOCK TABLES;*/
The text was updated successfully, but these errors were encountered:
If I make the 'reason' field signed, instead of unsigned, the issue goes away. This make it look as if it is the interpretation of the binary data (within mysql-native) which has an issue.
I've come across a problem when using LEAST() through mysql-native.
I have reproduced the behaviour in a testcase (below).
The query runs without any issues on the MySQL command line and produces:
The program below gives:
If I use the commented-out
reason AS reason_zero,
, mysql-native works (but that is not the query I need to run).If I use the commented-out
(reason > 0) AS reason_zero,
, I get the same failure mode.I'm using the latest mysql-native (from GitHub). (
git pull
told meUpdating 2b4f1ba..7677112
.)Thanks,
Chris.
P.S. Changing the column types in the database from
bigint
andsmallint
toint
does not fix the issue.The text was updated successfully, but these errors were encountered: