sidorares / mysqlite.js

sqlite db server talking mysql protocol, all native js
33 stars 1 forks source link

Doesn't Seem To Work #1

Open pspaulding opened 11 years ago

pspaulding commented 11 years ago

Windows 7 64 Node Version: v.0.10.9

C:\mysqlite\node_modules\mysqlite.js>node proxy.js 3307 db/development.sqlite
set autocommit=1
SQLite exception: 1, near "set": syntax error

buffer.js:343
    throw new RangeError('attempt to write beyond buffer bounds');
          ^
RangeError: attempt to write beyond buffer bounds
    at Buffer.write (buffer.js:343:11)
    at Packet.writeString (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\packets\packet.js:335:15)
    at Function.module.exports.Error.toPacket (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\packets\index.js:52:10)
    at Connection.writeError (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\connection.js:336:34)
    at C:\mysqlite\node_modules\mysqlite.js\proxy.js:51:23
    at Sql.module.exports.Sql.exec (C:\mysqlite\node_modules\mysqlite.js\node_modules\node-sqlite-purejs\js\node-sqlite-purejs.js:127:13)
    at Connection.<anonymous> (C:\mysqlite\node_modules\mysqlite.js\proxy.js:48:10)
    at Connection.EventEmitter.emit (events.js:95:17)
    at ServerHandshake.dispatchCommands (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\commands\server_handshake.js:60:16)
    at ServerHandshake.Command.execute (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\commands\command.js:23:20)

The error happens when I try connecting from mysql workbench.

sidorares commented 11 years ago

Thanks for reporting. I only tried it with command client. I'll check what commands workbench is sending

sidorares commented 11 years ago

can't reproduce same error. added some static queries fixtures, now WB disconnects after "SELECT current_user()", not sure why. Might worth looking at wb source

pspaulding commented 11 years ago

I just tried using the mysql command client and am getting similar results:

node:

C:\mysqlite\node_modules\mysqlite.js>node proxy.js 3307 db/development.sqlite

mysql:

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -h 127.0.0.1 -P 3307
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 0
Server version: node.js rocks

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

node:

select @@version_comment limit 1
SQLite exception: 1, unrecognized token: "@"

buffer.js:343
    throw new RangeError('attempt to write beyond buffer bounds');
          ^
RangeError: attempt to write beyond buffer bounds
    at Buffer.write (buffer.js:343:11)
    at Packet.writeString (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\packets\packet.js:335:15)
    at Function.module.exports.Error.toPacket (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\packets\index.js:52:10)
    at Connection.writeError (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\connection.js:336:34)
    at C:\mysqlite\node_modules\mysqlite.js\proxy.js:51:23
    at Sql.module.exports.Sql.exec (C:\mysqlite\node_modules\mysqlite.js\node_modules\node-sqlite-purejs\js\node-sqlite-purejs.js:127:13)
    at Connection.<anonymous> (C:\mysqlite\node_modules\mysqlite.js\proxy.js:48:10)
    at Connection.EventEmitter.emit (events.js:95:17)
    at ServerHandshake.dispatchCommands (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\commands\server_handshake.js:60:16)
    at ServerHandshake.Command.execute (C:\mysqlite\node_modules\mysqlite.js\node_modules\mysql2\lib\commands\command.js:23:20)

C:\mysqlite\node_modules\mysqlite.js>
sidorares commented 11 years ago

fixed packet size calculation here: https://github.com/sidorares/node-mysql2/commit/1ec11b39c972329b794fe1e9600680ec4c833301

for some reason this bug was silent on my setup (0.8.22, osx). Updated package.json to reference mysql2@0.8.12

pspaulding commented 11 years ago

Definite progress! I can now connect from the mysql command client and run the sample query.

  1. When first connecting using the command client, I am seeing the following from node:
select @@version_comment limit 1
SQLite exception: 1, unrecognized token: "@"

I don't know if this expected behavior.

  1. When attempting to connect from workbench, I can successfully "Test Connection", but when I try opening the connection into a session, this is the error that I get from workbench: image

And this is what I see from node:

set autocommit=1
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
SHOW SESSION VARIABLES LIKE 'lower_case_table_names'
SELECT current_user()
SET CHARACTER SET utf8
SET NAMES utf8

I am using 'root' for the username and am leaving the password field blank.

sidorares commented 11 years ago

at the moment there is no translation from mysql dialect to sqlite, and 'select @@version_comment limit 1' is invalid sqlite query. The only translation is in 'mysql_std.json' file - key is sql query, value - resultset. I'll try to trace which response make WB unhappy