-
Notifications
You must be signed in to change notification settings - Fork 2.5k
sequential query does not work #1
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
Comments
I've reproduced this same issue. It does indeed happen when you perform two or more SELECTs using the same database connection. This bug is quite the showstopper :-( It seems that FIELD_PACKET is not being emitted for subsequent SELECT queries. From my testing, it is instead receiving 4 ROW_DATA_PACKET events followed by 1 EOF_PACKET, 1 ROW_DATA_PACKET (this is the actual row in the table i'm assuming), and then 1 EOF_PACKET. For my example I have a database called 'testdb' and two tables, 'foo' and 'bar'. Querying 'foo' (SELECT * FROM foo)works as expected, but querying 'bar' (SELECT * FROM bar) does not. The 'bar' table contains two fields: 'myid' and 'mytitle'. I've found if I place this code right inside the beginning of the Parser.ROW_DATA_PACKET case in query.js, I am able to see the one row in the 'bar' table in the query results: With this modification, the query results contains: Hopefully this helps narrow down the problem some. I tried to find the root cause, but I am not well versed enough in the MySQL protocol to find it and this was as close as I could get to getting the actual row(s) back from the second SELECT query. |
I'm looking into this myself right now, it's just as you describe. I added a new debug mode for the client along with a failing test case. The output is:
This looks really weird, but I'll let you know once I found out what is going on. |
Ok, that was a silly bug in the parser. Fixed in 94ce814 |
Fixed Issue mysqljs#1
var db = new Client();
db.user = 'root';
db.password = 'root';
db.database = 'test';
db.connect();
db.query("SELECT SLEEP(1)",function(){console.log("First sleep");});
db.query("SELECT SLEEP(2)",function(){console.log("Second sleep");});
db.end();
Above script give below error;
itunali@itunali:~/nodejs$ ./bin/node my2.js
First sleep
/home/itunali/.node_libraries/mysql/query.js:42
field = this._fields[0];
^
TypeError: Cannot read property '0' of undefined
at Query._handlePacket (/home/itunali/.node_libraries/mysql/query.js:42:31)
at Client._handlePacket (/home/itunali/.node_libraries/mysql/client.js:194:14)
at Parser. (/home/itunali/.node_libraries/mysql/client.js:56:14)
at Parser.emit (events:26:26)
at Parser.write (/home/itunali/.node_libraries/mysql/parser.js:479:16)
at Stream. (/home/itunali/.node_libraries/mysql/client.js:51:16)
at Stream.emit (events:26:26)
at IOWatcher.callback (net:489:16)
at node.js:762:9
The text was updated successfully, but these errors were encountered: