GithubHelp home page GithubHelp logo

mysql's Introduction

mysql

NPM Version NPM Downloads Node.js Version Linux Build Windows Build Test Coverage

Table of Contents

Install

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.6 or higher is required.

Installation is done using the npm install command:

$ npm install mysql

For information about the previous 0.9.x releases, visit the v0.9 branch.

Sometimes I may also ask you to install the latest version from Github to check if a bugfix is working. In this case, please do:

$ npm install mysqljs/mysql

Introduction

This is a node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.

Here is an example on how to use it:

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'my_db'
});

connection.connect();

connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
  if (error) throw error;
  console.log('The solution is: ', results[0].solution);
});

connection.end();

From this example, you can learn the following:

  • Every method you invoke on a connection is queued and executed in sequence.
  • Closing the connection is done using end() which makes sure all remaining queries are executed before sending a quit packet to the mysql server.

Contributors

Thanks goes to the people who have contributed code to this module, see the GitHub Contributors page.

Additionally I'd like to thank the following people:

  • Andrey Hristov (Oracle) - for helping me with protocol questions.
  • Ulf Wendel (Oracle) - for helping me with protocol questions.

Sponsors

The following companies have supported this project financially, allowing me to spend more time on it (ordered by time of contribution):

Community

If you'd like to discuss this module, or ask questions about it, please use one of the following:

Establishing connections

The recommended way to establish a connection is this:

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'example.org',
  user     : 'bob',
  password : 'secret'
});

connection.connect(function(err) {
  if (err) {
    console.error('error connecting: ' + err.stack);
    return;
  }

  console.log('connected as id ' + connection.threadId);
});

However, a connection can also be implicitly established by invoking a query:

var mysql      = require('mysql');
var connection = mysql.createConnection(...);

connection.query('SELECT 1', function (error, results, fields) {
  if (error) throw error;
  // connected!
});

Depending on how you like to handle your errors, either method may be appropriate. Any type of connection error (handshake or network) is considered a fatal error, see the Error Handling section for more information.

Connection options

When establishing a connection, you can set the following options:

  • host: The hostname of the database you are connecting to. (Default: localhost)
  • port: The port number to connect to. (Default: 3306)
  • localAddress: The source IP address to use for TCP connection. (Optional)
  • socketPath: The path to a unix domain socket to connect to. When used host and port are ignored.
  • user: The MySQL user to authenticate as.
  • password: The password of that MySQL user.
  • database: Name of the database to use for this connection (Optional).
  • charset: The charset for the connection. This is called "collation" in the SQL-level of MySQL (like utf8_general_ci). If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used. (Default: 'UTF8_GENERAL_CI')
  • timezone: The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript Date object and vice versa. This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM. (Default: 'local')
  • connectTimeout: The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)
  • stringifyObjects: Stringify objects instead of converting to values. (Default: false)
  • insecureAuth: Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
  • typeCast: Determines if column values should be converted to native JavaScript types. (Default: true)
  • queryFormat: A custom query format function. See Custom format.
  • supportBigNumbers: When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false).
  • bigNumberStrings: Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately represented with [JavaScript Number objects] (https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type) (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.
  • dateStrings: Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather than inflated into JavaScript Date objects. Can be true/false or an array of type names to keep as strings. (Default: false)
  • debug: Prints protocol details to stdout. Can be true/false or an array of packet type names that should be printed. (Default: false)
  • trace: Generates stack traces on Error to include call site of library entrance ("long stack traces"). Slight performance penalty for most calls. (Default: true)
  • localInfile: Allow LOAD DATA INFILE to use the LOCAL modifier. (Default: true)
  • multipleStatements: Allow multiple mysql statements per query. Be careful with this, it could increase the scope of SQL injection attacks. (Default: false)
  • flags: List of connection flags to use other than the default ones. It is also possible to blacklist default ones. For more information, check Connection Flags.
  • ssl: object with ssl parameters or a string containing name of ssl profile. See SSL options.

In addition to passing these options as an object, you can also use a url string. For example:

var connection = mysql.createConnection('mysql://user:pass@host/db?debug=true&charset=BIG5_CHINESE_CI&timezone=-0700');

Note: The query values are first attempted to be parsed as JSON, and if that fails assumed to be plaintext strings.

SSL options

The ssl option in the connection options takes a string or an object. When given a string, it uses one of the predefined SSL profiles included. The following profiles are included:

When connecting to other servers, you will need to provide an object with any of the following options:

Here is a simple example:

var connection = mysql.createConnection({
  host : 'localhost',
  ssl  : {
    ca : fs.readFileSync(__dirname + '/mysql-ca.crt')
  }
});

You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.

var connection = mysql.createConnection({
  host : 'localhost',
  ssl  : {
    // DO NOT DO THIS
    // set up your ca correctly to trust the connection
    rejectUnauthorized: false
  }
});

Connection flags

If, for any reason, you would like to change the default connection flags, you can use the connection option flags. Pass a string with a comma separated list of items to add to the default flags. If you don't want a default flag to be used prepend the flag with a minus sign. To add a flag that is not in the default list, just write the flag name, or prefix it with a plus (case insensitive).

var connection = mysql.createConnection({
  // disable FOUND_ROWS flag, enable IGNORE_SPACE flag
  flags: '-FOUND_ROWS,IGNORE_SPACE'
});

The following flags are available:

  • COMPRESS - Enable protocol compression. This feature is not currently supported by the Node.js implementation so cannot be turned on. (Default off)
  • CONNECT_WITH_DB - Ability to specify the database on connection. (Default on)
  • FOUND_ROWS - Send the found rows instead of the affected rows as affectedRows. (Default on)
  • IGNORE_SIGPIPE - Don't issue SIGPIPE if network failures. This flag has no effect on this Node.js implementation. (Default on)
  • IGNORE_SPACE - Let the parser ignore spaces before the ( in queries. (Default on)
  • INTERACTIVE - Indicates to the MySQL server this is an "interactive" client. This will use the interactive timeouts on the MySQL server and report as interactive in the process list. (Default off)
  • LOCAL_FILES - Can use LOAD DATA LOCAL. This flag is controlled by the connection option localInfile. (Default on)
  • LONG_FLAG - Longer flags in Protocol::ColumnDefinition320. (Default on)
  • LONG_PASSWORD - Use the improved version of Old Password Authentication. (Default on)
  • MULTI_RESULTS - Can handle multiple resultsets for queries. (Default on)
  • MULTI_STATEMENTS - The client may send multiple statement per query or statement prepare (separated by ;). This flag is controlled by the connection option multipleStatements. (Default off)
  • NO_SCHEMA
  • ODBC Special handling of ODBC behaviour. This flag has no effect on this Node.js implementation. (Default on)
  • PLUGIN_AUTH - Uses the plugin authentication mechanism when connecting to the MySQL server. This feature is not currently supported by the Node.js implementation so cannot be turned on. (Default off)
  • PROTOCOL_41 - Uses the 4.1 protocol. (Default on)
  • PS_MULTI_RESULTS - Can handle multiple resultsets for execute. (Default on)
  • REMEMBER_OPTIONS - This is specific to the C client, and has no effect on this Node.js implementation. (Default off)
  • RESERVED - Old flag for the 4.1 protocol. (Default on)
  • SECURE_CONNECTION - Support native 4.1 authentication. (Default on)
  • SSL - Use SSL after handshake to encrypt data in transport. This feature is controlled though the ssl connection option, so the flag has no effect. (Default off)
  • SSL_VERIFY_SERVER_CERT - Verify the server certificate during SSL set up. This feature is controlled though the ssl.rejectUnauthorized connection option, so the flag has no effect. (Default off)
  • TRANSACTIONS - Asks for the transaction status flags. (Default on)

Terminating connections

There are two ways to end a connection. Terminating a connection gracefully is done by calling the end() method:

connection.end(function(err) {
  // The connection is terminated now
});

This will make sure all previously enqueued queries are still executed before sending a COM_QUIT packet to the MySQL server. If a fatal error occurs before the COM_QUIT packet can be sent, an err argument will be provided to the callback, but the connection will be terminated regardless of that.

An alternative way to end the connection is to call the destroy() method. This will cause an immediate termination of the underlying socket. Additionally destroy() guarantees that no more events or callbacks will be triggered for the connection.

connection.destroy();

Unlike end() the destroy() method does not take a callback argument.

Pooling connections

Rather than creating and managing connections one-by-one, this module also provides built-in connection pooling using mysql.createPool(config). Read more about connection pooling.

Create a pool and use it directly:

var mysql = require('mysql');
var pool  = mysql.createPool({
  connectionLimit : 10,
  host            : 'example.org',
  user            : 'bob',
  password        : 'secret',
  database        : 'my_db'
});

pool.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
  if (error) throw error;
  console.log('The solution is: ', results[0].solution);
});

This is a shortcut for the pool.getConnection() -> connection.query() -> connection.release() code flow. Using pool.getConnection() is useful to share connection state for subsequent queries. This is because two calls to pool.query() may use two different connections and run in parallel. This is the basic structure:

var mysql = require('mysql');
var pool  = mysql.createPool(...);

pool.getConnection(function(err, connection) {
  if (err) throw err; // not connected!

  // Use the connection
  connection.query('SELECT something FROM sometable', function (error, results, fields) {
    // When done with the connection, release it.
    connection.release();

    // Handle error after the release.
    if (error) throw error;

    // Don't use the connection here, it has been returned to the pool.
  });
});

If you would like to close the connection and remove it from the pool, use connection.destroy() instead. The pool will create a new connection the next time one is needed.

Connections are lazily created by the pool. If you configure the pool to allow up to 100 connections, but only ever use 5 simultaneously, only 5 connections will be made. Connections are also cycled round-robin style, with connections being taken from the top of the pool and returning to the bottom.

When a previous connection is retrieved from the pool, a ping packet is sent to the server to check if the connection is still good.

Pool options

Pools accept all the same options as a connection. When creating a new connection, the options are simply passed to the connection constructor. In addition to those options pools accept a few extras:

  • acquireTimeout: The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout, because acquiring a pool connection does not always involve making a connection. If a connection request is queued, the time the request spends in the queue does not count towards this timeout. (Default: 10000)
  • waitForConnections: Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue the connection request and call it when one becomes available. If false, the pool will immediately call back with an error. (Default: true)
  • connectionLimit: The maximum number of connections to create at once. (Default: 10)
  • queueLimit: The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there is no limit to the number of queued connection requests. (Default: 0)

Pool events

acquire

The pool will emit an acquire event when a connection is acquired from the pool. This is called after all acquiring activity has been performed on the connection, right before the connection is handed to the callback of the acquiring code.

pool.on('acquire', function (connection) {
  console.log('Connection %d acquired', connection.threadId);
});

connection

The pool will emit a connection event when a new connection is made within the pool. If you need to set session variables on the connection before it gets used, you can listen to the connection event.

pool.on('connection', function (connection) {
  connection.query('SET SESSION auto_increment_increment=1')
});

enqueue

The pool will emit an enqueue event when a callback has been queued to wait for an available connection.

pool.on('enqueue', function () {
  console.log('Waiting for available connection slot');
});

release

The pool will emit a release event when a connection is released back to the pool. This is called after all release activity has been performed on the connection, so the connection will be listed as free at the time of the event.

pool.on('release', function (connection) {
  console.log('Connection %d released', connection.threadId);
});

Closing all the connections in a pool

When you are done using the pool, you have to end all the connections or the Node.js event loop will stay active until the connections are closed by the MySQL server. This is typically done if the pool is used in a script or when trying to gracefully shutdown a server. To end all the connections in the pool, use the end method on the pool:

pool.end(function (err) {
  // all connections in the pool have ended
});

The end method takes an optional callback that you can use to know when all the connections are ended.

Once pool.end is called, pool.getConnection and other operations can no longer be performed. Wait until all connections in the pool are released before calling pool.end. If you use the shortcut method pool.query, in place of pool.getConnectionconnection.queryconnection.release, wait until it completes.

pool.end calls connection.end on every active connection in the pool. This queues a QUIT packet on the connection and sets a flag to prevent pool.getConnection from creating new connections. All commands / queries already in progress will complete, but new commands won't execute.

PoolCluster

PoolCluster provides multiple hosts connection. (group & retry & selector)

// create
var poolCluster = mysql.createPoolCluster();

// add configurations (the config is a pool config object)
poolCluster.add(config); // add configuration with automatic name
poolCluster.add('MASTER', masterConfig); // add a named configuration
poolCluster.add('SLAVE1', slave1Config);
poolCluster.add('SLAVE2', slave2Config);

// remove configurations
poolCluster.remove('SLAVE2'); // By nodeId
poolCluster.remove('SLAVE*'); // By target group : SLAVE1-2

// Target Group : ALL(anonymous, MASTER, SLAVE1-2), Selector : round-robin(default)
poolCluster.getConnection(function (err, connection) {});

// Target Group : MASTER, Selector : round-robin
poolCluster.getConnection('MASTER', function (err, connection) {});

// Target Group : SLAVE1-2, Selector : order
// If can't connect to SLAVE1, return SLAVE2. (remove SLAVE1 in the cluster)
poolCluster.on('remove', function (nodeId) {
  console.log('REMOVED NODE : ' + nodeId); // nodeId = SLAVE1
});

// A pattern can be passed with *  as wildcard
poolCluster.getConnection('SLAVE*', 'ORDER', function (err, connection) {});

// The pattern can also be a regular expression
poolCluster.getConnection(/^SLAVE[12]$/, function (err, connection) {});

// of namespace : of(pattern, selector)
poolCluster.of('*').getConnection(function (err, connection) {});

var pool = poolCluster.of('SLAVE*', 'RANDOM');
pool.getConnection(function (err, connection) {});
pool.getConnection(function (err, connection) {});
pool.query(function (error, results, fields) {});

// close all connections
poolCluster.end(function (err) {
  // all connections in the pool cluster have ended
});

PoolCluster options

  • canRetry: If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)
  • removeNodeErrorCount: If connection fails, node's errorCount increases. When errorCount is greater than removeNodeErrorCount, remove a node in the PoolCluster. (Default: 5)
  • restoreNodeTimeout: If connection fails, specifies the number of milliseconds before another connection attempt will be made. If set to 0, then node will be removed instead and never re-used. (Default: 0)
  • defaultSelector: The default selector. (Default: RR)
    • RR: Select one alternately. (Round-Robin)
    • RANDOM: Select the node by random function.
    • ORDER: Select the first node available unconditionally.
var clusterConfig = {
  removeNodeErrorCount: 1, // Remove the node immediately when connection fails.
  defaultSelector: 'ORDER'
};

var poolCluster = mysql.createPoolCluster(clusterConfig);

Switching users and altering connection state

MySQL offers a changeUser command that allows you to alter the current user and other aspects of the connection without shutting down the underlying socket:

connection.changeUser({user : 'john'}, function(err) {
  if (err) throw err;
});

The available options for this feature are:

  • user: The name of the new user (defaults to the previous one).
  • password: The password of the new user (defaults to the previous one).
  • charset: The new charset (defaults to the previous one).
  • database: The new database (defaults to the previous one).

A sometimes useful side effect of this functionality is that this function also resets any connection state (variables, transactions, etc.).

Errors encountered during this operation are treated as fatal connection errors by this module.

Server disconnects

You may lose the connection to a MySQL server due to network problems, the server timing you out, the server being restarted, or crashing. All of these events are considered fatal errors, and will have the err.code = 'PROTOCOL_CONNECTION_LOST'. See the Error Handling section for more information.

Re-connecting a connection is done by establishing a new connection. Once terminated, an existing connection object cannot be re-connected by design.

With Pool, disconnected connections will be removed from the pool freeing up space for a new connection to be created on the next getConnection call.

With PoolCluster, disconnected connections will count as errors against the related node, incrementing the error code for that node. Once there are more than removeNodeErrorCount errors on a given node, it is removed from the cluster. When this occurs, the PoolCluster may emit a POOL_NONEONLINE error if there are no longer any matching nodes for the pattern. The restoreNodeTimeout config can be set to restore offline nodes after a given timeout.

Performing queries

The most basic way to perform a query is to call the .query() method on an object (like a Connection, Pool, or PoolNamespace instance).

The simplest form of .query() is .query(sqlString, callback), where a SQL string is the first argument and the second is a callback:

connection.query('SELECT * FROM `books` WHERE `author` = "David"', function (error, results, fields) {
  // error will be an Error if one occurred during the query
  // results will contain the results of the query
  // fields will contain information about the returned results fields (if any)
});

The second form .query(sqlString, values, callback) comes when using placeholder values (see escaping query values):

connection.query('SELECT * FROM `books` WHERE `author` = ?', ['David'], function (error, results, fields) {
  // error will be an Error if one occurred during the query
  // results will contain the results of the query
  // fields will contain information about the returned results fields (if any)
});

The third form .query(options, callback) comes when using various advanced options on the query, like escaping query values, joins with overlapping column names, timeouts, and type casting.

connection.query({
  sql: 'SELECT * FROM `books` WHERE `author` = ?',
  timeout: 40000, // 40s
  values: ['David']
}, function (error, results, fields) {
  // error will be an Error if one occurred during the query
  // results will contain the results of the query
  // fields will contain information about the returned results fields (if any)
});

Note that a combination of the second and third forms can be used where the placeholder values are passed as an argument and not in the options object. The values argument will override the values in the option object.

connection.query({
    sql: 'SELECT * FROM `books` WHERE `author` = ?',
    timeout: 40000, // 40s
  },
  ['David'],
  function (error, results, fields) {
    // error will be an Error if one occurred during the query
    // results will contain the results of the query
    // fields will contain information about the returned results fields (if any)
  }
);

If the query only has a single replacement character (?), and the value is not null, undefined, or an array, it can be passed directly as the second argument to .query:

connection.query(
  'SELECT * FROM `books` WHERE `author` = ?',
  'David',
  function (error, results, fields) {
    // error will be an Error if one occurred during the query
    // results will contain the results of the query
    // fields will contain information about the returned results fields (if any)
  }
);

Escaping query values

Caution These methods of escaping values only works when the NO_BACKSLASH_ESCAPES SQL mode is disabled (which is the default state for MySQL servers).

Caution This library performs client-side escaping, as this is a library to generate SQL strings on the client side. The syntax for functions like mysql.format may look similar to a prepared statement, but it is not and the escaping rules from this module are used to generate a resulting SQL string. The purpose of escaping input is to avoid SQL Injection attacks. In order to support enhanced support like SET and IN formatting, this module will escape based on the shape of the passed in JavaScript value, and the resulting escaped string may be more than a single value. When structured user input is provided as the value to escape, care should be taken to validate the shape of the input to validate the output will be what is expected.

In order to avoid SQL Injection attacks, you should always escape any user provided data before using it inside a SQL query. You can do so using the mysql.escape(), connection.escape() or pool.escape() methods:

var userId = 'some user provided value';
var sql    = 'SELECT * FROM users WHERE id = ' + connection.escape(userId);
connection.query(sql, function (error, results, fields) {
  if (error) throw error;
  // ...
});

Alternatively, you can use ? characters as placeholders for values you would like to have escaped like this:

connection.query('SELECT * FROM users WHERE id = ?', [userId], function (error, results, fields) {
  if (error) throw error;
  // ...
});

Multiple placeholders are mapped to values in the same order as passed. For example, in the following query foo equals a, bar equals b, baz equals c, and id will be userId:

connection.query('UPDATE users SET foo = ?, bar = ?, baz = ? WHERE id = ?', ['a', 'b', 'c', userId], function (error, results, fields) {
  if (error) throw error;
  // ...
});

This looks similar to prepared statements in MySQL, however it really just uses the same connection.escape() method internally.

Caution This also differs from prepared statements in that all ? are replaced, even those contained in comments and strings.

Different value types are escaped differently, here is how:

  • Numbers are left untouched
  • Booleans are converted to true / false
  • Date objects are converted to 'YYYY-mm-dd HH:ii:ss' strings
  • Buffers are converted to hex strings, e.g. X'0fa5'
  • Strings are safely escaped
  • Arrays are turned into list, e.g. ['a', 'b'] turns into 'a', 'b'
  • Nested arrays are turned into grouped lists (for bulk inserts), e.g. [['a', 'b'], ['c', 'd']] turns into ('a', 'b'), ('c', 'd')
  • Objects that have a toSqlString method will have .toSqlString() called and the returned value is used as the raw SQL.
  • Objects are turned into key = 'val' pairs for each enumerable property on the object. If the property's value is a function, it is skipped; if the property's value is an object, toString() is called on it and the returned value is used.
  • undefined / null are converted to NULL
  • NaN / Infinity are left as-is. MySQL does not support these, and trying to insert them as values will trigger MySQL errors until they implement support.

This escaping allows you to do neat things like this:

var post  = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function (error, results, fields) {
  if (error) throw error;
  // Neat!
});
console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'

And the toSqlString method allows you to form complex queries with functions:

var CURRENT_TIMESTAMP = { toSqlString: function() { return 'CURRENT_TIMESTAMP()'; } };
var sql = mysql.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42

To generate objects with a toSqlString method, the mysql.raw() method can be used. This creates an object that will be left un-touched when using in a ? placeholder, useful for using functions as dynamic values:

Caution The string provided to mysql.raw() will skip all escaping functions when used, so be careful when passing in unvalidated input.

var CURRENT_TIMESTAMP = mysql.raw('CURRENT_TIMESTAMP()');
var sql = mysql.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42

If you feel the need to escape queries by yourself, you can also use the escaping function directly:

var query = "SELECT * FROM posts WHERE title=" + mysql.escape("Hello MySQL");

console.log(query); // SELECT * FROM posts WHERE title='Hello MySQL'

Escaping query identifiers

If you can't trust an SQL identifier (database / table / column name) because it is provided by a user, you should escape it with mysql.escapeId(identifier), connection.escapeId(identifier) or pool.escapeId(identifier) like this:

var sorter = 'date';
var sql    = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter);
connection.query(sql, function (error, results, fields) {
  if (error) throw error;
  // ...
});

It also supports adding qualified identifiers. It will escape both parts.

var sorter = 'date';
var sql    = 'SELECT * FROM posts ORDER BY ' + connection.escapeId('posts.' + sorter);
// -> SELECT * FROM posts ORDER BY `posts`.`date`

If you do not want to treat . as qualified identifiers, you can set the second argument to true in order to keep the string as a literal identifier:

var sorter = 'date.2';
var sql    = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter, true);
// -> SELECT * FROM posts ORDER BY `date.2`

Alternatively, you can use ?? characters as placeholders for identifiers you would like to have escaped like this:

var userId = 1;
var columns = ['username', 'email'];
var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId], function (error, results, fields) {
  if (error) throw error;
  // ...
});

console.log(query.sql); // SELECT `username`, `email` FROM `users` WHERE id = 1

Please note that this last character sequence is experimental and syntax might change

When you pass an Object to .escape() or .query(), .escapeId() is used to avoid SQL injection in object keys.

Preparing Queries

You can use mysql.format to prepare a query with multiple insertion points, utilizing the proper escaping for ids and values. A simple example of this follows:

var sql = "SELECT * FROM ?? WHERE ?? = ?";
var inserts = ['users', 'id', userId];
sql = mysql.format(sql, inserts);

Following this you then have a valid, escaped query that you can then send to the database safely. This is useful if you are looking to prepare the query before actually sending it to the database. As mysql.format is exposed from SqlString.format you also have the option (but are not required) to pass in stringifyObject and timezone, allowing you provide a custom means of turning objects into strings, as well as a location-specific/timezone-aware Date.

Custom format

If you prefer to have another type of query escape format, there's a connection configuration option you can use to define a custom format function. You can access the connection object if you want to use the built-in .escape() or any other connection function.

Here's an example of how to implement another format:

connection.config.queryFormat = function (query, values) {
  if (!values) return query;
  return query.replace(/\:(\w+)/g, function (txt, key) {
    if (values.hasOwnProperty(key)) {
      return this.escape(values[key]);
    }
    return txt;
  }.bind(this));
};

connection.query("UPDATE posts SET title = :title", { title: "Hello MySQL" });

Getting the id of an inserted row

If you are inserting a row into a table with an auto increment primary key, you can retrieve the insert id like this:

connection.query('INSERT INTO posts SET ?', {title: 'test'}, function (error, results, fields) {
  if (error) throw error;
  console.log(results.insertId);
});

When dealing with big numbers (above JavaScript Number precision limit), you should consider enabling supportBigNumbers option to be able to read the insert id as a string, otherwise it will throw an error.

This option is also required when fetching big numbers from the database, otherwise you will get values rounded to hundreds or thousands due to the precision limit.

Getting the number of affected rows

You can get the number of affected rows from an insert, update or delete statement.

connection.query('DELETE FROM posts WHERE title = "wrong"', function (error, results, fields) {
  if (error) throw error;
  console.log('deleted ' + results.affectedRows + ' rows');
})

Getting the number of changed rows

You can get the number of changed rows from an update statement.

"changedRows" differs from "affectedRows" in that it does not count updated rows whose values were not changed.

connection.query('UPDATE posts SET ...', function (error, results, fields) {
  if (error) throw error;
  console.log('changed ' + results.changedRows + ' rows');
})

Getting the connection ID

You can get the MySQL connection ID ("thread ID") of a given connection using the threadId property.

connection.connect(function(err) {
  if (err) throw err;
  console.log('connected as id ' + connection.threadId);
});

Executing queries in parallel

The MySQL protocol is sequential, this means that you need multiple connections to execute queries in parallel. You can use a Pool to manage connections, one simple approach is to create one connection per incoming http request.

Streaming query rows

Sometimes you may want to select large quantities of rows and process each of them as they are received. This can be done like this:

var query = connection.query('SELECT * FROM posts');
query
  .on('error', function(err) {
    // Handle error, an 'end' event will be emitted after this as well
  })
  .on('fields', function(fields) {
    // the field packets for the rows to follow
  })
  .on('result', function(row) {
    // Pausing the connnection is useful if your processing involves I/O
    connection.pause();

    processRow(row, function() {
      connection.resume();
    });
  })
  .on('end', function() {
    // all rows have been received
  });

Please note a few things about the example above:

  • Usually you will want to receive a certain amount of rows before starting to throttle the connection using pause(). This number will depend on the amount and size of your rows.
  • pause() / resume() operate on the underlying socket and parser. You are guaranteed that no more 'result' events will fire after calling pause().
  • You MUST NOT provide a callback to the query() method when streaming rows.
  • The 'result' event will fire for both rows as well as OK packets confirming the success of a INSERT/UPDATE query.
  • It is very important not to leave the result paused too long, or you may encounter Error: Connection lost: The server closed the connection. The time limit for this is determined by the net_write_timeout setting on your MySQL server.

Additionally you may be interested to know that it is currently not possible to stream individual row columns, they will always be buffered up entirely. If you have a good use case for streaming large fields to and from MySQL, I'd love to get your thoughts and contributions on this.

Piping results with Streams

The query object provides a convenience method .stream([options]) that wraps query events into a Readable Stream object. This stream can easily be piped downstream and provides automatic pause/resume, based on downstream congestion and the optional highWaterMark. The objectMode parameter of the stream is set to true and cannot be changed (if you need a byte stream, you will need to use a transform stream, like objstream for example).

For example, piping query results into another stream (with a max buffer of 5 objects) is simply:

connection.query('SELECT * FROM posts')
  .stream({highWaterMark: 5})
  .pipe(...);

Multiple statement queries

Support for multiple statements is disabled for security reasons (it allows for SQL injection attacks if values are not properly escaped). To use this feature you have to enable it for your connection:

var connection = mysql.createConnection({multipleStatements: true});

Once enabled, you can execute multiple statement queries like any other query:

connection.query('SELECT 1; SELECT 2', function (error, results, fields) {
  if (error) throw error;
  // `results` is an array with one element for every statement in the query:
  console.log(results[0]); // [{1: 1}]
  console.log(results[1]); // [{2: 2}]
});

Additionally you can also stream the results of multiple statement queries:

var query = connection.query('SELECT 1; SELECT 2');

query
  .on('fields', function(fields, index) {
    // the fields for the result rows that follow
  })
  .on('result', function(row, index) {
    // index refers to the statement this result belongs to (starts at 0)
  });

If one of the statements in your query causes an error, the resulting Error object contains a err.index property which tells you which statement caused it. MySQL will also stop executing any remaining statements when an error occurs.

Please note that the interface for streaming multiple statement queries is experimental and I am looking forward to feedback on it.

Stored procedures

You can call stored procedures from your queries as with any other mysql driver. If the stored procedure produces several result sets, they are exposed to you the same way as the results for multiple statement queries.

Joins with overlapping column names

When executing joins, you are likely to get result sets with overlapping column names.

By default, node-mysql will overwrite colliding column names in the order the columns are received from MySQL, causing some of the received values to be unavailable.

However, you can also specify that you want your columns to be nested below the table name like this:

var options = {sql: '...', nestTables: true};
connection.query(options, function (error, results, fields) {
  if (error) throw error;
  /* results will be an array like this now:
  [{
    table1: {
      fieldA: '...',
      fieldB: '...',
    },
    table2: {
      fieldA: '...',
      fieldB: '...',
    },
  }, ...]
  */
});

Or use a string separator to have your results merged.

var options = {sql: '...', nestTables: '_'};
connection.query(options, function (error, results, fields) {
  if (error) throw error;
  /* results will be an array like this now:
  [{
    table1_fieldA: '...',
    table1_fieldB: '...',
    table2_fieldA: '...',
    table2_fieldB: '...',
  }, ...]
  */
});

Transactions

Simple transaction support is available at the connection level:

connection.beginTransaction(function(err) {
  if (err) { throw err; }
  connection.query('INSERT INTO posts SET title=?', title, function (error, results, fields) {
    if (error) {
      return connection.rollback(function() {
        throw error;
      });
    }

    var log = 'Post ' + results.insertId + ' added';

    connection.query('INSERT INTO log SET data=?', log, function (error, results, fields) {
      if (error) {
        return connection.rollback(function() {
          throw error;
        });
      }
      connection.commit(function(err) {
        if (err) {
          return connection.rollback(function() {
            throw err;
          });
        }
        console.log('success!');
      });
    });
  });
});

Please note that beginTransaction(), commit() and rollback() are simply convenience functions that execute the START TRANSACTION, COMMIT, and ROLLBACK commands respectively. It is important to understand that many commands in MySQL can cause an implicit commit, as described in the MySQL documentation

Ping

A ping packet can be sent over a connection using the connection.ping method. This method will send a ping packet to the server and when the server responds, the callback will fire. If an error occurred, the callback will fire with an error argument.

connection.ping(function (err) {
  if (err) throw err;
  console.log('Server responded to ping');
})

Timeouts

Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout operations through the client. This means that when a timeout is reached, the connection it occurred on will be destroyed and no further operations can be performed.

// Kill query after 60s
connection.query({sql: 'SELECT COUNT(*) AS count FROM big_table', timeout: 60000}, function (error, results, fields) {
  if (error && error.code === 'PROTOCOL_SEQUENCE_TIMEOUT') {
    throw new Error('too long to count table rows!');
  }

  if (error) {
    throw error;
  }

  console.log(results[0].count + ' rows');
});

Error handling

This module comes with a consistent approach to error handling that you should review carefully in order to write solid applications.

Most errors created by this module are instances of the JavaScript Error object. Additionally they typically come with two extra properties:

  • err.code: String, contains the MySQL server error symbol if the error is a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'), a Node.js error code if it is a Node.js error (e.g. 'ECONNREFUSED'), or an internal error code (e.g. 'PROTOCOL_CONNECTION_LOST').
  • err.errno: Number, contains the MySQL server error number. Only populated from MySQL server error.
  • err.fatal: Boolean, indicating if this error is terminal to the connection object. If the error is not from a MySQL protocol operation, this property will not be defined.
  • err.sql: String, contains the full SQL of the failed query. This can be useful when using a higher level interface like an ORM that is generating the queries.
  • err.sqlState: String, contains the five-character SQLSTATE value. Only populated from MySQL server error.
  • err.sqlMessage: String, contains the message string that provides a textual description of the error. Only populated from MySQL server error.

Fatal errors are propagated to all pending callbacks. In the example below, a fatal error is triggered by trying to connect to a blocked port. Therefore the error object is propagated to both pending callbacks:

var connection = require('mysql').createConnection({
  port: 1 // example blocked port
});

connection.connect(function(err) {
  console.log(err.code); // 'ECONNREFUSED'
  console.log(err.fatal); // true
});

connection.query('SELECT 1', function (error, results, fields) {
  console.log(error.code); // 'ECONNREFUSED'
  console.log(error.fatal); // true
});

Normal errors however are only delegated to the callback they belong to. So in the example below, only the first callback receives an error, the second query works as expected:

connection.query('USE name_of_db_that_does_not_exist', function (error, results, fields) {
  console.log(error.code); // 'ER_BAD_DB_ERROR'
});

connection.query('SELECT 1', function (error, results, fields) {
  console.log(error); // null
  console.log(results.length); // 1
});

Last but not least: If a fatal errors occurs and there are no pending callbacks, or a normal error occurs which has no callback belonging to it, the error is emitted as an 'error' event on the connection object. This is demonstrated in the example below:

connection.on('error', function(err) {
  console.log(err.code); // 'ER_BAD_DB_ERROR'
});

connection.query('USE name_of_db_that_does_not_exist');

Note: 'error' events are special in node. If they occur without an attached listener, a stack trace is printed and your process is killed.

tl;dr: This module does not want you to deal with silent failures. You should always provide callbacks to your method calls. If you want to ignore this advice and suppress unhandled errors, you can do this:

// I am Chuck Norris:
connection.on('error', function() {});

Exception Safety

This module is exception safe. That means you can continue to use it, even if one of your callback functions throws an error which you're catching using 'uncaughtException' or a domain.

Type casting

For your convenience, this driver will cast mysql types into native JavaScript types by default. The default behavior can be changed through various Connection options. The following mappings exist:

Number

  • TINYINT
  • SMALLINT
  • INT
  • MEDIUMINT
  • YEAR
  • FLOAT
  • DOUBLE
  • BIGINT

Date

  • TIMESTAMP
  • DATE
  • DATETIME

Buffer

  • TINYBLOB
  • MEDIUMBLOB
  • LONGBLOB
  • BLOB
  • BINARY
  • VARBINARY
  • BIT (last byte will be filled with 0 bits as necessary)

String

Note text in the binary character set is returned as Buffer, rather than a string.

  • CHAR
  • VARCHAR
  • TINYTEXT
  • MEDIUMTEXT
  • LONGTEXT
  • TEXT
  • ENUM
  • SET
  • DECIMAL (may exceed float precision)
  • TIME (could be mapped to Date, but what date would be set?)
  • GEOMETRY (never used those, get in touch if you do)

It is not recommended (and may go away / change in the future) to disable type casting, but you can currently do so on either the connection:

var connection = require('mysql').createConnection({typeCast: false});

Or on the query level:

var options = {sql: '...', typeCast: false};
var query = connection.query(options, function (error, results, fields) {
  if (error) throw error;
  // ...
});

Custom type casting

You can also pass a function and handle type casting yourself. You're given some column information like database, table and name and also type and length. If you just want to apply a custom type casting to a specific type you can do it and then fallback to the default.

The function is provided two arguments field and next and is expected to return the value for the given field by invoking the parser functions through the field object.

The field argument is a Field object and contains data about the field that need to be parsed. The following are some of the properties on a Field object:

  • db - a string of the database the field came from.
  • table - a string of the table the field came from.
  • name - a string of the field name.
  • type - a string of the field type in all caps.
  • length - a number of the field length, as given by the database.

The next argument is a function that, when called, will return the default type conversion for the given field.

When getting the field data, the following helper methods are present on the field object:

  • .string() - parse the field into a string.
  • .buffer() - parse the field into a Buffer.
  • .geometry() - parse the field as a geometry value.

The MySQL protocol is a text-based protocol. This means that over the wire, all field types are represented as a string, which is why only string-like functions are available on the field object. Based on the type information (like INT), the type cast should convert the string field into a different JavaScript type (like a number).

Here's an example of converting TINYINT(1) to boolean:

connection = mysql.createConnection({
  typeCast: function (field, next) {
    if (field.type === 'TINY' && field.length === 1) {
      return (field.string() === '1'); // 1 = true, 0 = false
    } else {
      return next();
    }
  }
});

WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.

Debugging and reporting problems

If you are running into problems, one thing that may help is enabling the debug mode for the connection:

var connection = mysql.createConnection({debug: true});

This will print all incoming and outgoing packets on stdout. You can also restrict debugging to packet types by passing an array of types to debug:

var connection = mysql.createConnection({debug: ['ComQueryPacket', 'RowDataPacket']});

to restrict debugging to the query and data packets.

If that does not help, feel free to open a GitHub issue. A good GitHub issue will have:

  • The minimal amount of code required to reproduce the problem (if possible)
  • As much debugging output and information about your environment (mysql version, node version, os, etc.) as you can gather.

Security issues

Security issues should not be first reported through GitHub or another public forum, but kept private in order for the collaborators to assess the report and either (a) devise a fix and plan a release date or (b) assert that it is not a security issue (in which case it can be posted in a public forum, like a GitHub issue).

The primary private forum is email, either by emailing the module's author or opening a GitHub issue simply asking to whom a security issues should be addressed to without disclosing the issue or type of issue.

An ideal report would include a clear indication of what the security issue is and how it would be exploited, ideally with an accompanying proof of concept ("PoC") for collaborators to work against and validate potentional fixes against.

Contributing

This project welcomes contributions from the community. Contributions are accepted using GitHub pull requests. If you're not familiar with making GitHub pull requests, please refer to the GitHub documentation "Creating a pull request".

For a good pull request, we ask you provide the following:

  1. Try to include a clear description of your pull request in the description. It should include the basic "what" and "why"s for the request.
  2. The tests should pass as best as you can. See the Running tests section on how to run the different tests. GitHub will automatically run the tests as well, to act as a safety net.
  3. The pull request should include tests for the change. A new feature should have tests for the new feature and bug fixes should include a test that fails without the corresponding code change and passes after they are applied. The command npm run test-cov will generate a coverage/ folder that contains HTML pages of the code coverage, to better understand if everything you're adding is being tested.
  4. If the pull request is a new feature, please be sure to include all appropriate documentation additions in the Readme.md file as well.
  5. To help ensure that your code is similar in style to the existing code, run the command npm run lint and fix any displayed issues.

Running tests

The test suite is split into two parts: unit tests and integration tests. The unit tests run on any machine while the integration tests require a MySQL server instance to be setup.

Running unit tests

$ FILTER=unit npm test

Running integration tests

Set the environment variables MYSQL_DATABASE, MYSQL_HOST, MYSQL_PORT, MYSQL_USER and MYSQL_PASSWORD. MYSQL_SOCKET can also be used in place of MYSQL_HOST and MYSQL_PORT to connect over a UNIX socket. Then run npm test.

For example, if you have an installation of mysql running on localhost:3306 and no password set for the root user, run:

$ mysql -u root -e "CREATE DATABASE IF NOT EXISTS node_mysql_test"
$ MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_DATABASE=node_mysql_test MYSQL_USER=root MYSQL_PASSWORD= FILTER=integration npm test

Todo

  • Prepared statements
  • Support for encodings other than UTF-8 / ASCII

mysql's People

Contributors

alsotang avatar balihoo-jflitton avatar captainoz avatar demian85 avatar dougwilson avatar dresende avatar felixge avatar grncdr avatar ifsnow avatar imkira avatar jflitton avatar kai-koch avatar kylew avatar marcuswestin avatar maxnachlinger avatar mintbridge avatar mscdex avatar nanek avatar nataliewolfe avatar nwoltman avatar rwky avatar seanmonstar avatar sidorares avatar sixmen avatar stoke avatar tellnes avatar tgpfeiffer avatar tomasikp avatar whoughton avatar zjonsson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mysql's Issues

"Bad handshake" on connect

The client does not work at all for me - the tests fail. When I turn on debug mode, I see a "Bad handshake" error.

<- GREETING_PACKET: {"length":52,"received":52,"number":0,"type":0,"protocolVersion":10,"serverVersion":"5.0.77","threadId":3315809,"scrambleBuffer":{"0":94,"1":85,"2":109,"3":73,"4":96,"5":43,"6":81,"7":56,"8":98,"9":103,"10":95,"11":40,"12":69,"13":97,"14":60,"15":69,"16":39,"17":51,"18":106,"19":62,"length":20},"serverCapabilities":41516,"serverLanguage":8,"serverStatus":2}
-> <Buffer 47 00 00 01 cf f7 03 00 00 00 00 01 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 72 6f 6f 74 00 14 3a 38 b0 b9 00 90 e0 06 f3 1e 5f 63 95 08 5e e0 e2 03 4c 72 6e 6f 64 65 6a 73 5f 6d 79 73 71 6c 00>
<- RESULT_SET_HEADER_PACKET: {"length":1,"received":1,"number":2,"type":3,"fieldCount":0}
-> <Buffer 11 00 00 00 03 55 53 45 20 6e 6f 64 65 6a 73 5f 6d 79 73 71 6c>
<- FIELD_PACKET: {"length":22,"received":22,"number":3,"type":4,"catalog":"Bad handshake"}

My test code looks like this:

var Client = require('mysql').Client;
var client = new Client();
client.user = 'root';
client.password = 'root';
client.database = 'nodejs_mysql';
client.debug = true;
client.on('error', function(){ console.log('error'); });
client.connect(function(){ console.log('connect'); });
client.query('USE nodejs_mysql', function(){ console.log('query'); });

None of the callbacks fire.

Suddenly I cannot excecute a simple query...

Seriously, what the fuck is going on? this code was working properly and suddenly the weirdest thing happends..
Well, the actual code uses a real user and password... but still does not work.

[email protected] and [email protected]

var mysql = require('mysql');
var db = new mysql.Client();
db.debug = true;
db.user = 'nonexistenuser';
db.password = 'asgjv5h3i6hvb3k643';
db.host = 'wtf?';
db.database = 'nonexistentdatabase';

db.on('error', function(err) {
   console.log(err)
});

db.connect(function() {
   console.log('Mysql connection established.');
   db.query("SELECT * FROM Campaigns", [], function(err, result) {
   console.log(result)
   })
});

And the output is "Mysql connection established."

?????????

client.query(sql, [params, cb]) ---> 'too many parameters given'

I'm trying to do something like:

client.query(
    'SELECT uid FROM sessions WHERE sid="?"',
    [sid, function selectCb(err, results, fields) {
        //...
    }]
);

but it throws an exception:

$PATH/.npm/mysql/0.9.0/package/lib/mysql/client.js:167
    throw new Error('too many parameters given');

Am I missing something?

(node v0.2.4, node-mysql v0.9.0)

What happens, if you select more than 100 datasets (rows)?!

Hello to all,
Felix thanks for your work, I heard about nodejs first time at the chaosradio podcast, so I tried it.
At the point, when I select more than 100 rows, the program does not work properly.
Sometimes i got rows sometimes not.
client.query(
//'SELECT id,a,b FROM '+TABLE+' limit 0,400',
'SELECT 1+1 as sum FROM '+TABLE,
function selectCb(err, results, fields) {
console.log('result handler start');
if (err) {
console.log("ERROR: " + err.message);
throw err;
}
console.log("Got "+results.length+" Rows:");
//console.log(results);
client.end();
console.log('finished.');
}
);
When I set the limit to more than 1001 rows, i never get any result.
Note: I never get an error, but the result handler is not executed. Whenever I expect an empty result (seen at the example above), the result handler is also not executed.

Are there any limits for js-Arrays, or what happens there?

Best regards

Jirko Kegler

ECONNREFUSED, Connection refused

Hey Felix,

I sarted using your lib just yesterday, and it worked perfectly on my Macbook, but when trying to move it to my stage environment, it's returning an ECONNREFUSED, Connection refused error (errno: 111).
Tried using different users (even root) and same thing.
I am using Ubuntu Karmic Koala with mysql 5.0.

Do you have an idea of what can it be?, should I upgrade mysql?

Regards
Juan Silva

blob fields issue

By default the blob fields are encoded in utf8 (query.js: row[field.name] += buffer.toString('utf-8');).
You can't safely convert a binary to UTF8 without loss of data. To convert binary data to text, use Base64 encoding instead:
For TINY_BLOB,MEDIUM_BLOB, LONG_BLOB,TYPE_BLOB :
row[field.name] += buffer.toString('base64');)

Documentation about client.connect

I'm planning on using node-mysql in a project and am wonder when the best time to connect to a server is...

Should I do it once per request, or when I start the server?

Is there a way to check if it is connected before I run a query (like with client.connected or something) so I can quickly connect if I need to?

What happens if I call client.connect() multiple times? Does it do nothing if the server it is connecting to it is already connected to?

Any advice would be great!

mysql_insert_id functionality

Maybe i am missing something, but i can't see any way to get the new id when a row is inserted into an autonumber column in the database. is this possible? if not, would it be a big deal to add it? i can work on a patch if you like...

nulls values

Hi,

NULLs values (dates/numbers/integers) are not properly handled.

Try:

select date_column from table where date_column is null;

In query.js :

row[field.name] = new Date(row[field.name]+'Z'); // row[field.name] is null !

Insert ID...

Can you document how to get the ID of the row inserted by a INSERT query?
By looking through the code it even seems like this is not yet possible, even though it is implemented in the Parser. Could you add this feature if it is not present yet?

Also, as a side question, is it possible to make a blocking/synchronous query (e.g. function does an insert and returns the id of the inserted row)?

val.replace in Client.prototype.escape is undefined

Upon issuing a query with a parameter array, sometimes node crashes on line 183 of client.js:

val = val.replace(/[\0\n\r\b\t\\\'\"\x1a]/g, function(s) {

with the exception that the object has no replace method. Wrapping this whole thing in a check if the object has a replace method is keeping my server running.

database.length error

/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/client.js:229
this.database.length + 1
^
TypeError: Cannot read property 'length' of null
at Client._sendAuth (/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/client.js:229:22)
at Client._handlePacket (/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/client.js:193:10)
at Parser. (/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/client.js:57:14)
at Parser.emit (events:26:26)
at /usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/parser.js:71:14
at Parser.write (/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/parser.js:537:7)
at Stream. (/usr/local/lib/node/.npm/mysql/0.3.0/package/lib/mysql/client.js:52:16)
at Stream.emit (events:26:26)
at IOWatcher.callback (net:489:16)
at node.js:772:9

Multiple Statement Execution (SERVER_MORE_RESULTS_EXISTS)

Hello Felix,

how difficult would it be to support multiple statements in one query, like BEGIN; SELECT 1; SELECT 2; COMMIT?

I think both having query(...) invoke the callback function multiple times and introduce something like multiQuery(...), where the callback gets arrays of rows and fields, would work fine.

Best regards,
René

can't connect with mysql 5.1 ?

Am I doing something wrong? Thanks!

Server version: 5.1.31-1ubuntu2 (Ubuntu)

reproducing code:
var Client = require('./node-mysql/lib/mysql').Client,
client = new Client();

client.user = 'root';
client.password = 'password';
client.host = 'localhost';
client.port = 3306;

client.connect();

output:

crypto:3638
return new Hash(hash);
^
TypeError: undefined is not a function
at CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at Object.createHash (crypto:3638:10)
at sha1 (/usr/local/Singularity/node-mysql/lib/mysql/auth.js:5:21)
at Object.token (/usr/local/Singularity/node-mysql/lib/mysql/auth.js:28:16)
at Client._sendAuth (/usr/local/Singularity/node-mysql/lib/mysql/client.js:230:20)
at Client._handlePacket (/usr/local/Singularity/node-mysql/lib/mysql/client.js:194:10)
at Parser. (/usr/local/Singularity/node-mysql/lib/mysql/client.js:58:14)
at Parser.emit (events:26:26)
at /usr/local/Singularity/node-mysql/lib/mysql/parser.js:72:14
at Parser.write (/usr/local/Singularity/node-mysql/lib/mysql/parser.js:545:7)

query error behavior

According to the readme, the client's 'error' event is emitted when a query has no callback / delegate for an error.

This works fine for queries that have been created with a callback. However if a delegate is attached through client.on('error', cb), the client's error event is emitted anyway.

Try:

query = client.query('this must be wrong');
query.on('error', function(err) {
  console.log('Failing gracefully: ' + error);
});

Error: EMFILE, Too many open files

Connections often became stale and so as a result I was recreating / restarting connections before timeout to ensure freshness, over time the following error occurred:

20 Nov 20:15:01 - Error: EMFILE, Too many open files
at net:907:19
at Object.lookup (dns:138:5)
at Stream.connect (net:902:9)
at connect (/usr/local/lib/node/.npm/mysql/0.8.0/package/lib/mysql/client.js:79:16)
at Client._prequeue (/usr/local/lib/node/.npm/mysql/0.8.0/package/lib/mysql/client.js:245:3)
at Stream. (/usr/local/lib/node/.npm/mysql/0.8.0/package/lib/mysql/client.js:77:14)
at Stream.emit (events:27:15)
at IOWatcher.callback (net:471:53)
at node.js:772:9

Here is the code that was resetting the connection:

var sphinx = new Client(),
    client = new Client(),
    mysqlReset = 300000;

sphinx.user = 'XXXXX';
sphinx.port = '9306';
sphinx.host = '127.0.0.1';
sphinx.connect();

client.user = 'xxxxxxx';
client.password = 'XXXXXX;
client.database = 'XXXXXX';
client.host = '127.0.0.1';
client.connect();

setInterval(function() {
    resetMysql(client,function(newClient) {
        client = newClient;
    });
    resetMysql(sphinx,function(newClient) {
        sphinx = newClient;
    });
}, mysqlReset);

function resetMysql(old, cb) {
    var temp = new Client();
    for (var i in old) {
        if (old.hasOwnProperty(i) && typeof old[i] != 'undefined' && old[i] !== null && old[i].constructor != Function) {
            temp[i] = old[i];   
        }
    };
    temp.connect(function() {
        cb(temp);
        old.end();
    });
}

Non blocking query

Hi,

I am at a loss, I am doing a simple SELECT query and the javascript continues on its merry way before the query has a chance to return.

mysql.query('SELECT roles, IP, user_id FROM user WHERE user_name = \''+ username +'\'',
  function(err, results) 
  {
        if (err) {
            throw err;
             sys.log('Error ' +err);
        }
        else
      {
            user_role = results[0].roles;
            cip = results[0].IP;
            uid = results[0].user_id;
          sys.log('got result from sql');
      }
  });

sys.log(user_role+' '+cip+' '+uid);

This is inside a function and the last line always displays before 'got result from sql' and the function has already returned empty results.

Am I doing something wrong?

Query results off-by-one in stored procedure callback

To replicate the problem:

Call a stored procedure using the module, then in the callback for the stored procedure perform another query. The results of that inner query seems to be status information related to the outer stored procedure call. If you run yet another query inside that callback, you will get the results of the first inner query.

First run the following code to setup the test database:

-- CREATE TEST DATABASE
DROP DATABASE IF EXISTS testdb123;
CREATE DATABASE testdb123;
USE testdb123;

-- DEFINE A BASIC STORED PROCEDURE
DELIMITER $$
CREATE PROCEDURE testproc() BEGIN
    SELECT 'sproc result';
END $$
DELIMITER ;

Then run the following code in Node.js to replicate the problem:

// Connect to MySQL
var MySqlClient = require('mysql').Client;
var client = new MySqlClient(
{
    user: 'root',
    password: 'letmein',
    database: 'testdb123'

});
client.connect();

client.query(
    'CALL testproc()',
    function(inError, inResult) {

        console.log('Stored procedure result:');
        console.log(inResult);

        client.query(
            "SELECT 'one'",
            function(inError, inResult) {

                console.log('First query result (should be one):')
                console.log(inResult);

                client.query(
                    "SELECT 'two'",
                    function(inError, inResult) {

                        console.log('Second query result (should be two):')
                        console.log(inResult);

                    }
                );

            }
        );

    }
);


setTimeout(
    function() {

        client.query(
                    "SELECT 'three'",
            function(inError, inResult) {

                console.log('Third query result (should be three):')
                console.log(inResult);

            }
        );

    },
    2500
);

The output is:

Stored procedure result:
[ { 'sproc result': 'sproc result' } ]
First query result (should be one):
{ affectedRows: 0
, insertId: 0
, serverStatus: 2
, warningCount: 0
, message: ''
, emit: [Function]
, addListener: [Function]
, on: [Function]
, removeListener: [Function]
, removeAllListeners: [Function]
, listeners: [Function]
}
Second query result (should be two):
[ { one: 'one' } ]
Third query result (should be three):
[ { three: 'three' } ]

Insert multiple rows fails

Hello,

I tried to insert multiple rows with one insert. Syntax like this: "INSERT INTO foo VALUES ('a'), ('b'), ('c')". I got the following Error, this looks for me like a bug:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: too few parameters given
    at /usr/local/lib/node/.npm/mysql/0.9.1/package/lib/mysql/client.js:160:13
    at String.replace (native)
    at Client.format (/usr/local/lib/node/.npm/mysql/0.9.1/package/lib/mysql/client.js:158:13)
    at Client.query (/usr/local/lib/node/.npm/mysql/0.9.1/package/lib/mysql/client.js:92:16)
    at /home/node/primarywall/dbMigration.js:70:12
    at /usr/local/lib/node/.npm/async/0.1.8/package/lib/async.js:484:34
    at Array. (/usr/local/lib/node/.npm/async/0.1.8/package/lib/async.js:408:34)
    at EventEmitter._tickCallback (node.js:126:26)

Allow UNIX domain socket

Hi,

I found using "/var/run/mysqld/mysqld.sock" being 10 to 20 % faster than a local TCP connection. Esp. connecting is almost immediately.

I'd suggest setting host = null and setting port appropriately (if different from default) should open a local IPC connection. My diffs and it's follow up would do the trick.

I guess windows' named pipes should be usable the same way. Having no windows installation, I cannot help you with that. ;)

Greetings
René

Convert to New Wikis

Please convert the project to the new Wiki system. I was going to start taking notes on issues I was encountering, but adding to the old Wiki system only creates problems.

add transaction handling to Client prototype

would it be okay to add transaction handling to the client as per the following patch, or something along these lines?

Client.prototype.begin = function(callback) {
    var client = this;
    this.query("SET autocommit=0", function(err, info) {
        if(err) {
            callback(err);
        }
        else {
            client.query("START TRANSACTION", function(err, info) {
                if(err) {
                    callback(err);
                }
                else {
                    callback(null, info);
                }
            });
        }
    });
};

Client.prototype.commit = function(callback) {
    var client = this;
    this.query("COMMIT", function(err, info) {
        if(err) {
            callback(err);
        }
        else {
            client.query("SET autocommit=1", function(err, info) {
                if(err) {
                    callback(err);
                }
                else {
                    callback(null, info);
                }
            });
        }
    });
};

Client.prototype.rollback = function(callback) {
    var client = this;
    this.query("ROLLBACK", function(err, info) {
        if(err) {
            callback(err);
        }
        else {
            client.query("SET autocommit=1", function(err, info) {
                if(err) {
                    callback(err);
                }
                else {
                    callback(null, info);
                }
            });
        }
    });
};

sequential query does not work

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

Support for old (< 4.1) passwords

Mysql uses some homebrew hashing and scrambling code for old passwords which needs to be ported to Javascript.

I have started some initial work here:

http://github.com/felixge/node-mysql/commit/0cb56d994641bad3426fd5cfc7e452f7903bc059

hash_password seems to be successfully ported, but I could need help with:

  • randominit
  • my_rnd
  • scramble_323

See this link for details:

http://github.com/felixge/node-mysql/blob/0cb56d994641bad3426fd5cfc7e452f7903bc059/test/fixture/libmysql_password.c#L34-72

Charset Handling

The characters returned by the client.query call is not utf8. Resulting in a scrambled output using special foreign language characters. Wouldn't it be good to use utf8 as standard charset ?

Calcuated Field Packets do Not Parse Correctly

Calculated fields do not have a db name, original table name, table name, or original field name. The parser reads the count of characters for the db name, then assumes that the next byte is the first character in the db name, adds it to a buffer, then checks to see if the character count has been reached, but now it is past the character count and so the packet contents are assigned to the db name.

I've created a patch and submitted a pull request.

results.insertId is zero when not using auto_increment

So, I'd expected that a line like

c.query('INSERT INTO bar SET id = ?', ['baz'], function(err, results) {
  console.log(results.insertId);
});

would show either baz or undefined; instead, it gives 0. The behavior is the same if id is an INT being set to some arbitrary value—unless AUTO_INCREMENT is set, in which case the value is returned (whether set by the query or by the server).

Looking at parser.js, I'm guessing that the MySQL protocol simply doesn't provide insertId at all unless AUTO_INCREMENT is set, and lengthCoded is converting that undefined result to 0. Perhaps in the interest of clarity, it would be better to omit the insertId key from the results hash altogether in such cases?

Error: ENOTFOUND, Domain name not found

im not sure what happen but everything seem working fine except the node-mysql
anyone know how to resolve this?
thx

$ node sql.js

events:12
throw arguments[1];
^
Error: ENOTFOUND, Domain name not found
at IOWatcher.callback (dns:53:15)
at node.js:772:9

create table breaks select callback result

Hi Felix,

I'm running into weird behavior where the expected second argument to a db.query('select…') callback isn't an array of result rows when I execute a drop/create table before hand.

Here's a reduced reproduction: https://gist.github.com/674861

And here's a couple of runs:

$ NO_TABLE=1 node node-mysql-bug-repro.js 
[ { id: 3
  , c_string: 'hello'
  , c_number: 42
  , c_date: null
  , c_boolean: null
  }
]
success!

$ node node-mysql-bug-repro.js 
{ affectedRows: 1
, insertId: 1
, serverStatus: 2
, warningCount: 0
, message: ''
, emit: [Function]
, addListener: [Function]
, on: [Function]
, removeListener: [Function]
, removeAllListeners: [Function]
, listeners: [Function]
}

assert:80
  throw new assert.AssertionError({
        ^
AssertionError: true == false
    at /Users/wolf/code/github/node-mysql-oil/test/node-mysql-bug-repro.js:19:18
    at Query.<anonymous> (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/client.js:117:11)
    at Query.emit (events:27:15)
    at Query._handlePacket (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/query.js:31:12)
    at Client._handlePacket (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/client.js:290:14)
    at Parser.<anonymous> (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/client.js:83:14)
    at Parser.emit (events:27:15)
    at /usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/parser.js:75:14
    at Parser.write (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/parser.js:580:7)
    at Stream.<anonymous> (/usr/local/lib/node/.npm/mysql/0.8.0-1-LINK-a7d29606/package/lib/mysql/client.js:63:16)

I'm on node v0.2.4 and this commit of node-mysql

how to get mysql error code?

Is there a way to capture mysql error code when an error occurs? I need to detect errors for duplicate inserts. thanks.

node-mysql can not handle longtext fields with > 250 chars

Hello there,

I created a table with one longtext column and put in the following string (just for testing)

http://pastie.org/1112094

It is 250 characters long.
This is my node.js code for selecting the data from the database:

this.client.query('SELECT * FROM tickets LIMIT 1', function(err, results, fields) {
  console.log("ticket available");
  return null;
});

Works fine for the 250 character string. As soon as I add another 0 the query will not load and be stuck in a kind of infinite loop.

Address already in use after opening and closing 7000+ connections

Hi, I'm doing a bit of testing. In my server I open a MySQL connection when a client connects and close it again when the request ends. Simple enough. This seem to work fine for about 7000 requests (sequential, no concurrent requests), but then I get an "Address already in use" exception:

node.js:60
    throw e;
    ^
Error: EADDRINUSE, Address already in use
    at doConnect (net:821:19)
    at net:892:9
    at dns:165:36
    at Object.lookup (dns:163:17)
    at Stream.connect (net:886:9)
    at connect (/Users/zef/.node_libraries/.npm/mysql/0.4.0/package/lib/mysql/client.js:47:16)
    at Client._enqueue (/Users/zef/.node_libraries/.npm/mysql/0.4.0/package/lib/mysql/client.js:174:5)
    at Client.connect (/Users/zef/.node_libraries/.npm/mysql/0.4.0/package/lib/mysql/client.js:43:8)

Any clues as for why this may happen? Maybe the connections don't really get closed? Although my mysqladmin processlist doesn't show any open connections.

Errors end up in wrong callback

In a complex log parse/insert script, I have queries that look approximately like this:

  • BEGIN TRANSACTION
  • (lots of insert statements)
  • insert that causes a duplicate key failure
  • COMMIT TRANSACTION

When there are only few insert statements, the callback for the duplicate key failure insert contains the error object, but when there are lots of them, the err value will be null and node-mysql proceeds to commit transaction, also calls it without an error object and at some later point fires an error event on the global database object.

SHOW tables and SHOW columns don't work as expected

When a SHOW TABLES or SHOW COLUMNS FROM [table] query is performed, the data returning is not in a format that is easy to parse.

When performing SHOW TABLES the field name is undefined, resulting in an object with a series of undefined keys. The values are correct

When performing SHOW COLUMNS FROM [table] the result isn't usable: the contents of results and fields by using sys.inspect:

22 Aug 14:58:28 - results: [ { undefined: 'auto_increment' } ]
22 Aug 14:58:28 - fields: { undefined:
{ length: 39
, received: 39
, number: 7
, type: 4
, catalog: 'def'
, db: '\u0007COLUMNS\u0000\u0005Extra\u0005EXTRA\f\b\u0000\u0014\u0000\u0000\u0000\u00fd\u0001\u0000\u0000\u0000\u0000'
}
}

connection charset

I'm connecting to a database that has latin1 as charset on all tables, but when I send the data via nodejs to the client, the extended characters are broken (I suppose because nodejs and javascript in general user utf-8 as default encoding).

I try to change the client.charsetNumber but I'm not sure what the number means (and what are valida ones). I take a look at the mysql protocol without luck.

The working demo is running at [1], and basically is pulling all post from a vbulletin database and creating a 'timeline' in realtime, with nodejs on the server.

Any help is appreciated :)

[1] http://playground.3dgames.com.ar/3dg-live/index.html

Handle "too many connections" error

Seems like yet another undocumented gem in the mysql protocol:

<- GREETING_PACKET: {"length":135,"received":135,"number":0,"type":0,"protocolVersion":255,"serverVersion":"i\u0004Host 'domU-12-31-39-10-71-32.compute-1.intern
al' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"}

/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/auth.js:30
  var stage3 = sha1(scramble.toString('binary') + stage2);
                             ^
TypeError: Cannot call method 'toString' of undefined
    at Object.token (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/auth.js:30:30)
    at Client._sendAuth (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/client.js:308:20)
    at Client._handlePacket (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/client.js:271:10)
    at Parser.<anonymous> (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/client.js:83:14)
    at Parser.emit (events:27:15)
    at /usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/parser.js:75:14
    at Parser.write (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/parser.js:565:7)
    at Stream.<anonymous> (/usr/local/lib/node/.npm/mysql/0.7.0/package/lib/mysql/client.js:64:16)
    at Stream.emit (events:27:15)
    at IOWatcher.callback (net:489:16)

Closed connections stuck in CLOSE_WAIT

This may be related to #43 - the symptom in my app was that I ran out of file descriptors. lsof revealed that I was leaking mysql connections.

I have traced the origins of this issue to changes made between the npm 0.6.0 and 0.7.0 releases. 0.7.0 and 0.8.0 appear to have this issue.

Here's some examples (my app code is unchanged across these runs):

james@ubuntu:~/nook$ npm install [email protected]
james@ubuntu:~/nook$ node app.js &
(access webapp in browser)
james@ubuntu:~/nook$ sudo lsof -p 4981 -P -n | grep 3306
node    4981 james    8u  IPv4 825503      0t0     TCP 127.0.0.1:53629->127.0.0.1:3306 (CLOSE_WAIT)
(make another request in browser)
james@ubuntu:~/nook$ sudo lsof -p 4981 -P -n | grep 3306
node    4981 james    8u  IPv4 825503      0t0     TCP 127.0.0.1:53629->127.0.0.1:3306 (CLOSE_WAIT)
node    4981 james    9u  IPv4 825662      0t0     TCP 127.0.0.1:53630->127.0.0.1:3306 (CLOSE_WAIT)

Downgrade to 0.6.0:

james@ubuntu:~/nook$ npm install [email protected]
james@ubuntu:~/nook$ node app.js &
(access webapp in browser)
james@ubuntu:~/nook$ sudo lsof -p 5013 -P -n | grep 3306
(no output - as expected)
(access webapp 10x times in browser)
james@ubuntu:~/nook$ sudo lsof -p 5013 -P -n | grep 3306
(no output - as expected)

I will see if I can figure out what changed between releases. My guess is the conn.end() behavior has changed. From the documentation it sounds like end() attempts to gracefully close the connection. Perhaps another packet needs to be sent after the COM_QUIT?

thank you

-- James

How to avoid long nesting?

Ok, this is not specific to this module, but I came across it while trying to build something meaningful with it:

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  var html = "<h1>Demo</h1>";
  getSomeDate(client, function(someData) {
    html += "<p>"+ someData +"</p>";
    getSomeOtherDate(client, function(someOtherData) {
      html += "<p>"+ someOtherData +"</p>";
      getMoreData(client, function(moreData) {
        html += "<p>"+ moreData +"</p>";
        res.write(html);
        res.end();
      });
    });
  });

where:

getSomeData = function(client, callback) {
  client.query(...);
}

How can I avoid this long nesting in cases like the above where I want to do multiple consecutive queries that depend on each other, like: get id, then get username for later id, ..., then get X for later Y,...

npm issue

$ sudo npm install mysql
npm info it worked if it ends with ok
npm info version 0.1.27-12
npm ERR! Error: ucs {bad_utf8_character_code}: mysql
npm ERR! at IncomingMessage. (/usr/local/lib/node/.npm/npm/0.1.27-12/package/lib/utils/registry/request.js:83:19)
npm ERR! at IncomingMessage.emit (events:43:20)
npm ERR! at HTTPParser.onMessageComplete (http:107:23)
npm ERR! at Client.ondata (http:882:22)
npm ERR! at IOWatcher.callback (net:494:29)
npm ERR! at node.js:764:9
npm ERR! try running: 'npm help install'
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm not ok

Also posted this on npm site
On osx 10.6

Regards
Juan silva

Parser chokes

If I do a SELECT * query on a certain table, the parser chokes.

/cygdrive/d/nodejs/node-mysql/lib/mysql/parser.js:517
          packet.emit('data', buffer.slice(i, i + remaining), 0);
                                     ^
TypeError: Bad argument.

I find it difficult to follow the execution flow of the parser, so I haven't been able to track down the origin of the bug, other than that lengthCoded raises 256 by -1 which results in a non-integer value being decoded. Below is a table export of a table that causes the same error.

In the meantime I wrote my own little parser (http://github.com/piscisaureus/node-mysql/commits/alt-parser) which does work fine but is way slower than yours...

Bert

/*Table structure for table `test` */
CREATE TABLE `test` (
  `id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `contactId` bigint(20) unsigned NOT NULL DEFAULT '0',
  `objectId` bigint(20) unsigned NOT NULL DEFAULT '0',
  `action` int(11) NOT NULL DEFAULT '0',
  `description1` text NOT NULL,
  `description2` text NOT NULL,
  `comment` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

/*Data for the table `test` */
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2040211,2040021,1036909,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy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Id`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2044202,2044199,364256,20,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','zzzzzzz');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2044238,184385,1036579,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2047577,2040021,2047578,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2047581,2040021,386892,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2047582,2040021,2047578,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2050978,179420,176278,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2052501,184385,166606,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2054090,184385,1065201,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2055134,184385,1077968,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2057343,1463197,2016982,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2057344,1463197,2057345,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2057358,1463197,2057345,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2057359,1463197,2057360,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2057363,1463197,2057348,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2058964,184385,163536,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2061432,184385,2061433,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2061707,2061704,2060549,20,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy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yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','zzzzzzz');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2062953,170918,170918,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2064796,2064793,896653,20,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2073522,1595377,2073523,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2073526,1595377,2073527,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2073530,1595377,2073531,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2073920,1291266,2073921,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2073962,1291266,2073963,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081135,1595377,2081136,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081139,1595377,1270731,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081791,2081788,1205754,20,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081842,1414175,1810599,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081843,1414175,1647740,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2081981,1414175,1647740,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2091288,303082,2091289,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2094622,178774,186536,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2095304,2095301,236644,20,'xxxxxxxxxxxxxxx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yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','zzzzzzz');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2096354,236594,2095305,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2096772,1414175,168272,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2098608,184385,1830520,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2098609,184385,334553,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyy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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','zzzzzzz');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2098751,1291260,2073921,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2098752,1291260,1534493,3,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2099469,1725755,1096303,2,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');
insert  into `test`(`id`,`contactId`,`objectId`,`action`,`description1`,`description2`,`comment`) values (2102576,1725755,2102577,1,'','yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy','');

Query callback doesn't seem to fire after some requests...

The newest changes to the parser and query seem to break the query callback at some point.
Last working commit is 4a93056.

What happens in my case is that a series of fetches have been done, then a query for a single record is performed, but the callback for that query never fires, nor does it for any subsequent query.
The only thing that I have been able to find out about this problem is that it is introduced in commit 09df6f9, in parser.js, the new code included from line 496.

Unicode -> Utf8 encoding ?

Hello,

I'm having issues while trying to insert strings containing characters like "éèçà" that get converted to something like "éééàçç", how can I change that behavior ? is it because of the stream's encoding ? how to change it ?

Thanks !

Getting the wrong column

Hey,

I'm now running node-mysql in a socketserver with ~15 requests per second. Every request I'm fetching information from a table called "servers" which contains columns called id, subdomain, cpu and workdir. And sometimes when I want to use the value of the workdir column it gives me the value of the cpu column. So server.workdir then contains the value of the cpu column.

Did anyone experience something like that yet?

Make queries pause()able

It should be possible to pause an incoming data stream, e.g. the query object should cease emitting row/field/whatever events and the tcp connection to the mysql server should be put on hold too.

Case: a project I'm working on has a database with >800k filenames that I need to walk through and perform some file operations on those files. Because file and db operations are asynchronous, node-mysql will spit out a new row while the file operations associated with previous rows are still running. So I end up with way too may callbacks/stacks floating around, which causes out-of-memory errors and extreme slowness.

Currently I'm using a hack that 'just' pauses the underlying tcp stream; that works, but after I pause the tcp stream I still receive 500-some row events before it gets silent. I guess those rows must be buffered up somewhere.

I think the most elegant solution would be to have a pause() and a resume() method on Query objects. A caveat would be that when doing something like ...

var q1 = client.query('SELECT something');
var q2 = client.query('SELECT something');
q2.pause();

... q1 should not be paused, so bluntly pausing the tcp stream when q2.pause() is called is not the way to go.

(IMHO it would be even cooler if we could pause the tcp stream automatically when appropriate, but I don't think there currently is a reliable way to measure stack / event loop pressure within node)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.