不要怂,就是干,撸起袖子干!

Commit 27a67a99 by Mick Hansen

Revert "Feature #488 : Added benchmarking support in query logs"

1 parent 59ddc4b8
# 3.17.0 # 3.17.0
- [CRITICAL] Fixed injection vulnerability for order/limit - [CRITICAL] Fixed injection vulnerability for order/limit
- [FIXED] MySQL throws error when null GEOMETRY data results in empty buffer [#4953](https://github.com/sequelize/sequelize/issues/4953) - [FIXED] MySQL throws error when null GEOMETRY data results in empty buffer [#4953](https://github.com/sequelize/sequelize/issues/4953)
- [ADDED] Support for benchmarking the execution time for SQL queries [#488](https://github.com/sequelize/sequelize/issues/488)
# 3.16.0 # 3.16.0
- [ADDED] PostgreSQL tsrange (Range of timestamp without time zone) data type support. - [ADDED] PostgreSQL tsrange (Range of timestamp without time zone) data type support.
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
var Utils = require('../../utils') var Utils = require('../../utils')
, AbstractQuery = require('../abstract/query') , AbstractQuery = require('../abstract/query')
, sequelizeErrors = require('../../errors.js') , sequelizeErrors = require('../../errors.js')
, parserStore = require('../parserStore')('mssql') , parserStore = require('../parserStore')('mssql');
, microtime = require('microtime');
var Query = function(connection, sequelize, options) { var Query = function(connection, sequelize, options) {
this.connection = connection; this.connection = connection;
...@@ -31,14 +30,7 @@ Query.prototype.run = function(sql, parameters) { ...@@ -31,14 +30,7 @@ Query.prototype.run = function(sql, parameters) {
var self = this; var self = this;
this.sql = sql; this.sql = sql;
//do we need benchmark for this query execution
var benchmark = this.sequelize.options.benchmark || this.options.benchmark;
if (!benchmark) {
this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql, this.options); this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql, this.options);
} else {
var queryBegin = microtime.now();
}
var promise = new Utils.Promise(function(resolve, reject) { var promise = new Utils.Promise(function(resolve, reject) {
// TRANSACTION SUPPORT // TRANSACTION SUPPORT
...@@ -71,11 +63,6 @@ Query.prototype.run = function(sql, parameters) { ...@@ -71,11 +63,6 @@ Query.prototype.run = function(sql, parameters) {
var results = []; var results = [];
var request = new self.connection.lib.Request(self.sql, function(err) { var request = new self.connection.lib.Request(self.sql, function(err) {
if (benchmark) {
self.sequelize.log('Executed (' + (self.connection.uuid || 'default') + '): ' + self.sql + ' in ' + (microtime.now() - queryBegin) + 'μs', self.options);
}
if (err) { if (err) {
err.sql = sql; err.sql = sql;
reject(self.formatError(err)); reject(self.formatError(err));
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
var Utils = require('../../utils') var Utils = require('../../utils')
, AbstractQuery = require('../abstract/query') , AbstractQuery = require('../abstract/query')
, uuid = require('node-uuid') , uuid = require('node-uuid')
, sequelizeErrors = require('../../errors.js') , sequelizeErrors = require('../../errors.js');
, microtime = require('microtime');
var Query = function(connection, sequelize, options) { var Query = function(connection, sequelize, options) {
this.connection = connection; this.connection = connection;
...@@ -27,22 +26,10 @@ Query.prototype.run = function(sql, parameters) { ...@@ -27,22 +26,10 @@ Query.prototype.run = function(sql, parameters) {
var self = this; var self = this;
this.sql = sql; this.sql = sql;
//do we need benchmark for this query execution
var benchmark = this.sequelize.options.benchmark || this.options.benchmark;
if (!benchmark) {
this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql, this.options); this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql, this.options);
} else {
var queryBegin = microtime.now();
}
var promise = new Utils.Promise(function(resolve, reject) { var promise = new Utils.Promise(function(resolve, reject) {
self.connection.query(self.sql, function(err, results) { self.connection.query(self.sql, function(err, results) {
if (benchmark) {
self.sequelize.log('Executed (' + (self.connection.uuid || 'default') + '): ' + self.sql + ' in ' + (microtime.now() - queryBegin) + 'μs', self.options);
}
if (err) { if (err) {
err.sql = sql; err.sql = sql;
......
...@@ -5,8 +5,7 @@ var Utils = require('../../utils') ...@@ -5,8 +5,7 @@ var Utils = require('../../utils')
, QueryTypes = require('../../query-types') , QueryTypes = require('../../query-types')
, Promise = require('../../promise') , Promise = require('../../promise')
, sequelizeErrors = require('../../errors.js') , sequelizeErrors = require('../../errors.js')
, _ = require('lodash') , _ = require('lodash');
, microtime = require('microtime');
var Query = function(client, sequelize, options) { var Query = function(client, sequelize, options) {
this.client = client; this.client = client;
...@@ -63,14 +62,7 @@ Query.prototype.run = function(sql, parameters) { ...@@ -63,14 +62,7 @@ Query.prototype.run = function(sql, parameters) {
, query = ((parameters && parameters.length) ? this.client.query(this.sql, parameters) : this.client.query(this.sql)) , query = ((parameters && parameters.length) ? this.client.query(this.sql, parameters) : this.client.query(this.sql))
, rows = []; , rows = [];
//do we need benchmark for this query execution
var benchmark = this.sequelize.options.benchmark || this.options.benchmark;
if (!benchmark) {
this.sequelize.log('Executing (' + (this.client.uuid || 'default') + '): ' + this.sql, this.options); this.sequelize.log('Executing (' + (this.client.uuid || 'default') + '): ' + this.sql, this.options);
} else {
var queryBegin = microtime.now();
}
var promise = new Promise(function(resolve, reject) { var promise = new Promise(function(resolve, reject) {
query.on('row', function(row) { query.on('row', function(row) {
...@@ -90,11 +82,6 @@ Query.prototype.run = function(sql, parameters) { ...@@ -90,11 +82,6 @@ Query.prototype.run = function(sql, parameters) {
}); });
query.on('end', function(result) { query.on('end', function(result) {
if (benchmark) {
self.sequelize.log('Executed (' + (self.client.uuid || 'default') + '): ' + self.sql + ' in ' + (microtime.now() - queryBegin) + 'μs', self.options);
}
if (receivedError) { if (receivedError) {
return; return;
} }
......
...@@ -6,8 +6,7 @@ var Utils = require('../../utils') ...@@ -6,8 +6,7 @@ var Utils = require('../../utils')
, AbstractQuery = require('../abstract/query') , AbstractQuery = require('../abstract/query')
, QueryTypes = require('../../query-types') , QueryTypes = require('../../query-types')
, sequelizeErrors = require('../../errors.js') , sequelizeErrors = require('../../errors.js')
, parserStore = require('../parserStore')('sqlite') , parserStore = require('../parserStore')('sqlite');
, microtime = require('microtime');
var Query = function(database, sequelize, options) { var Query = function(database, sequelize, options) {
this.database = database; this.database = database;
...@@ -85,14 +84,7 @@ Query.prototype.run = function(sql, parameters) { ...@@ -85,14 +84,7 @@ Query.prototype.run = function(sql, parameters) {
this.sql = sql; this.sql = sql;
} }
//do we need benchmark for this query execution
var benchmark = this.sequelize.options.benchmark || this.options.benchmark;
if (!benchmark) {
this.sequelize.log('Executing (' + (this.database.uuid || 'default') + '): ' + this.sql, this.options); this.sequelize.log('Executing (' + (this.database.uuid || 'default') + '): ' + this.sql, this.options);
} else {
var queryBegin = microtime.now();
}
promise = new Promise(function(resolve) { promise = new Promise(function(resolve) {
var columnTypes = {}; var columnTypes = {};
...@@ -103,11 +95,6 @@ Query.prototype.run = function(sql, parameters) { ...@@ -103,11 +95,6 @@ Query.prototype.run = function(sql, parameters) {
} else { } else {
resolve(new Promise(function(resolve, reject) { resolve(new Promise(function(resolve, reject) {
var afterExecute = function(err, results) { var afterExecute = function(err, results) {
if (benchmark) {
self.sequelize.log('Executed (' + (self.database.uuid || 'default') + '): ' + self.sql + ' in ' + (microtime.now() - queryBegin) + 'μs', self.options);
}
if (err) { if (err) {
err.sql = self.sql; err.sql = self.sql;
reject(self.formatError(err)); reject(self.formatError(err));
......
...@@ -81,8 +81,7 @@ var url = require('url') ...@@ -81,8 +81,7 @@ var url = require('url')
* @param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. * @param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them.
* @param {String} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. * @param {String} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only.
* @param {String} [options.isolationLevel='REPEATABLE_READ'] Set the default transaction isolation level. See `Sequelize.Transaction.ISOLATION_LEVELS` for possible options. * @param {String} [options.isolationLevel='REPEATABLE_READ'] Set the default transaction isolation level. See `Sequelize.Transaction.ISOLATION_LEVELS` for possible options.
* @param {Boolean} [options.typeValidation=false] Run built in type validators on insert and update, e.g. validate that arguments passed to integer fields are integer-like. * @param {Boolean} [options.typeValidation=false] Run built in type validators on insert and update, e.g. validate that arguments passed to integer fields are integer-like
* @param {Boolean} [options.benchmark=false] Print query execution time in microseconds when logging SQL.
*/ */
/** /**
...@@ -148,8 +147,7 @@ var Sequelize = function(database, username, password, options) { ...@@ -148,8 +147,7 @@ var Sequelize = function(database, username, password, options) {
transactionType: Transaction.TYPES.DEFERRED, transactionType: Transaction.TYPES.DEFERRED,
isolationLevel: Transaction.ISOLATION_LEVELS.REPEATABLE_READ, isolationLevel: Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
databaseVersion: 0, databaseVersion: 0,
typeValidation: false, typeValidation: false
benchmark: false
}, options || {}); }, options || {});
if (this.options.dialect === 'postgresql') { if (this.options.dialect === 'postgresql') {
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
"inflection": "^1.6.0", "inflection": "^1.6.0",
"lodash": "^3.9.3", "lodash": "^3.9.3",
"moment": "^2.11.0", "moment": "^2.11.0",
"microtime": "^2.0.0",
"moment-timezone": "^0.5.0", "moment-timezone": "^0.5.0",
"node-uuid": "~1.4.4", "node-uuid": "~1.4.4",
"semver": "^5.0.1", "semver": "^5.0.1",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!