Mysql: DELIMITER within conn.query() throws an Error

Created on 27 Aug 2012  路  1Comment  路  Source: mysqljs/mysql

The following sql statements are held in 1 (of many) .sql files which run against a database, to bootstrap the db.

DROP TABLE IF EXISTS `alerts`;
CREATE TABLE `alerts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` char(50) COLLATE utf8_bin NOT NULL DEFAULT '',
  `type` char(255) CHARACTER SET latin1 NOT NULL,
  `message` text COLLATE utf8_bin NOT NULL,
  `timestamp` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `type` (`type`) USING BTREE,
  KEY `timestamp` (`timestamp`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
delimiter ;;
CREATE TRIGGER `beforeInsert_alerts` BEFORE INSERT ON `alerts` FOR EACH ROW SET new.uuid = uuid();
 ;;
delimiter ;

When I execute that from conn.query(), with mutlipleStatements: true, I get the following error:

Error: ER_PARSE_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 $$                      
CREATE TRIGGER `beforeInsert_alerts` BEFORE INSERT ON `alerts` FOR ' at line 1                                                                                                                  
    at Function.Sequence.packetToError (/Users/jason/Projects/FileTrek/Dashboard/node_modules/mysql/lib/protocol/sequences/Sequence.js:30:14)                                                   
    at Query.ErrorPacket (/Users/jason/Projects/FileTrek/Dashboard/node_modules/mysql/lib/protocol/sequences/Query.js:59:22)                                                                    
    at Protocol._parsePacket (/Users/jason/Projects/FileTrek/Dashboard/node_modules/mysql/lib/protocol/Protocol.js:143:24)                                                                      
    at Parser.write (/Users/jason/Projects/FileTrek/Dashboard/node_modules/mysql/lib/protocol/Parser.js:42:10)                                                                                  
    at Protocol.write (/Users/jason/Projects/FileTrek/Dashboard/node_modules/mysql/lib/protocol/Protocol.js:31:18)
    at Socket.ondata (stream.js:38:26)
    at Socket.EventEmitter.emit (events.js:88:17)
    at TCP.onread (net.js:395:14)

Changing the delimiter to $$, or any other character(s) doesn't change the result.

Most helpful comment

DELIMITER is not part of MySQL server, it's part of the MySQL command line client. This feature is not available in my driver (or any other MySQL driver that I'm aware of, including PHP, etc.).

>All comments

DELIMITER is not part of MySQL server, it's part of the MySQL command line client. This feature is not available in my driver (or any other MySQL driver that I'm aware of, including PHP, etc.).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bologer picture bologer  路  3Comments

EdoardoPedrotti picture EdoardoPedrotti  路  3Comments

skilbjo picture skilbjo  路  3Comments

Rhapsody-Sky picture Rhapsody-Sky  路  3Comments

JCQuintas picture JCQuintas  路  3Comments