Permalink
Browse files

Silenced "SHOW FIELDS" and "SET SQL_AUTO_IS_NULL=0" statements from t…

…he MySQL driver to improve log signal to noise ration in development [DHH]
  • Loading branch information...
dhh committed Feb 6, 2010
1 parent 3caca40 commit 28fe0c330a2081b1709522274c0b1b193e50ee20
Showing with 13 additions and 4 deletions.
  1. +5 −0 activerecord/CHANGELOG
  2. +8 −4 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
View
@@ -1,5 +1,10 @@
*Edge*
+* Silenced "SHOW FIELDS" and "SET SQL_AUTO_IS_NULL=0" statements from the MySQL driver to improve log signal to noise ration in development [DHH]
+
+
+*Rails 3.0 [Beta] (February 4th, 2010)*
+
* PostgreSQLAdapter: set time_zone to UTC when Base.default_timezone == :utc so that Postgres doesn't incorrectly offset-adjust values inserted into TIMESTAMP WITH TIME ZONE columns. #3777 [Jack Christensen]
* Allow relations to be used as scope.
@@ -321,7 +321,11 @@ def select_rows(sql, name = nil)
# Executes a SQL query and returns a MySQL::Result object. Note that you have to free the Result object after you're done using it.
def execute(sql, name = nil) #:nodoc:
- log(sql, name) { @connection.query(sql) }
+ if name == :skip_logging
+ @connection.query(sql)
+ else
+ log(sql, name) { @connection.query(sql) }
+ end
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings."
@@ -456,7 +460,7 @@ def indexes(table_name, name = nil)#:nodoc:
def columns(table_name, name = nil)#:nodoc:
sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}"
columns = []
- result = execute(sql, name)
+ result = execute(sql, :skip_logging)
result.each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") }
result.free
columns
@@ -616,11 +620,11 @@ def connect
def configure_connection
encoding = @config[:encoding]
- execute("SET NAMES '#{encoding}'") if encoding
+ execute("SET NAMES '#{encoding}'", :skip_logging) if encoding
# By default, MySQL 'where id is null' selects the last inserted id.
# Turn this off. http://dev.rubyonrails.org/ticket/6778
- execute("SET SQL_AUTO_IS_NULL=0")
+ execute("SET SQL_AUTO_IS_NULL=0", :skip_logging)
end
def select(sql, name = nil)

0 comments on commit 28fe0c3

Please sign in to comment.