code: function smartRunSQL(pool, sql, params, tx, callback) {
      if (tx) {
          // run in transaction:
          return executeSQL(tx.connection, sql, params, callback);
      }
      pool.getConnection(function (err, conn) {
          if (err) {
              log('?', 'CONNECTION', 'get connection failed.');
              return callback(err);
          }
          setConnectionObjectId(conn);
          poolSize ++;
          log(conn, 'CONNECTION', 'opened from pool: ' + poolSize);
          executeSQL(conn, sql, params, function (err, result) {
              conn.release();
              poolSize --;
              log(conn, 'CONNECTION', 'released to pool: ' + poolSize);
              callback(err, result);
          });
      });
  }
docs: run sql in new connection or join the transaction: