sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
4.09k stars 625 forks source link

DELIMITER causes syntax error #2723

Open tomcatmwi opened 6 months ago

tomcatmwi commented 6 months ago

It seems that DELIMITER commands aren't forwarded to the MySQL server properly.

DELIMITER $$
DELIMITER ;

This is perfectly correct, and runs fine from DBeaver or even the MySQL command line. Yet with mysql2 it will throw a syntax error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$
DELIMITER' at line 1

Complete debug log:

 raw: 0a382e302e3335006e0000000a6a5a26652a2a5100ffffff0200ffdf1500000000000000000000215e353d756b2531477933600063616368696e675f736861325f70617373776f726400
Trace
    at PoolConnection.handlePacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:433:17)
    at PacketParser.onPacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
0 undefined ==> ClientHandshake#unknown name(0,,78)
Server hello packet: capability flags:3758096383=(long password, found rows, long flag, connect with db, no schema, compress, odbc, local files, ignore space, protocol 41, interactive, ssl, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, connect attrs, plugin auth lenenc client data, can handle expired passwords, session track, deprecate eof, ssl verify server cert, remember options, multi factor authentication)
Sending handshake packet: flags:280753103=(long password, found rows, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, plugin auth, connect attrs, plugin auth lenenc client data, session track, multi factor authentication)
0 110 <== ClientHandshake#unknown name(1,,139)
0 110 <== 87000001cff3bb1000000000e00000000000000000000000000000000000000000000000726f6f740014f2d29f77b09fa87beac84217da20fe7e23c082477261646172006d7973716c5f6e61746976655f70617373776f726400300c5f636c69656e745f6e616d650c4e6f64652d4d7953514c2d320f5f636c69656e745f76657273696f6e05332e392e37
 raw: fe63616368696e675f736861325f70617373776f7264000a6a5a26652a2a51215e353d756b25314779336000
Trace
    at PoolConnection.handlePacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:433:17)
    at PacketParser.onPacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
0 110 ==> ClientHandshake#unknown name(2,,48)
0 110 <== ClientHandshake#unknown name(3,,36)
0 110 <== 2000000354ee7d4e2f038954de9994a7d8f2b1790e923f2fcee91497bc32bbb950031b0f
 raw: 0103
Trace
    at PoolConnection.handlePacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:433:17)
    at PacketParser.onPacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
0 110 ==> ClientHandshake#unknown name(4,,6)
 raw: 0000000240000000080106057261646172
Trace
    at PoolConnection.handlePacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:433:17)
    at PacketParser.onPacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
0 110 ==> ClientHandshake#unknown name(5,maybeOK,21)
Add command: Query
        Sending query command: 
DELIMITER $$
DELIMITER ;
0 110 <== Query#unknown name(0,,30)
0 110 <== 1a000000030a44454c494d495445522024240a44454c494d49544552203b
 raw: ff2804233432303030596f75206861766520616e206572726f7220696e20796f75722053514c2073796e7461783b20636865636b20746865206d616e75616c207468617420636f72726573706f6e647320746f20796f7572204d7953514c207365727665722076657273696f6e20666f72207468652072696768742073796e74617820746f20757365206e656172202744454c494d495445522024240a44454c494d4954455227206174206c696e652031
Trace
    at PoolConnection.handlePacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:433:17)
    at PacketParser.onPacket (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/home/tomcatmwi/Project/Media Crawler Top Gun/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:376:12)
    at readableAddChunk (node:internal/streams/readable:349:9)
    at Readable.push (node:internal/streams/readable:286:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
0 110 ==> Query#unknown name(1,Error,181)
JaoodxD commented 4 months ago

@tomcatmwi similar to me. Have you found any solution?