Permalink
Browse files

Merge pull request #10571 from dasch/dasch/restore-explain-fix

Don't try to EXPLAIN select_db calls
  • Loading branch information...
2 parents e2804c6 + ddaa5d5 commit 5c6cf4e59e3e9c75395541162f2741b82347af0a @rafaelfranca rafaelfranca committed May 11, 2013
@@ -1,5 +1,9 @@
## unreleased ##
+* Make sure the `EXPLAIN` command is never triggered by a `select_db` call.
+
+ *Daniel Schierbeck*
+
* Revert changes on `pluck` that was ignoring the select clause when the relation already
has one. This caused a regression since it changed the behavior in a stable release.
@@ -15,7 +15,7 @@ def call(*args)
# On the other hand, we want to monitor the performance of our real database
# queries, not the performance of the access to the query cache.
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE)
- EXPLAINED_SQLS = /\A\s*(select|update|delete|insert)/i
+ EXPLAINED_SQLS = /\A\s*(select|update|delete|insert)\b/i
def ignore_payload?(payload)
payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name]) || payload[:sql] !~ EXPLAINED_SQLS
end
@@ -38,6 +38,13 @@ def test_collects_pairs_of_queries_and_binds
end
end
+ def test_collects_nothing_if_the_statement_is_only_partially_matched
+ with_queries([]) do |queries|
+ SUBSCRIBER.call(:name => 'SQL', :sql => 'select_db yo_mama')
+ assert queries.empty?
+ end
+ end
+
def test_collects_nothing_if_unexplained_sqls
with_queries([]) do |queries|
SUBSCRIBER.call(:name => 'SQL', :sql => 'SHOW max_identifier_length')

0 comments on commit 5c6cf4e

Please sign in to comment.