Skip to content

Business intelligence made simple

Added support for MariaDB timeouts

Andrew Kane9d76b3b56f35
diff --git a/lib/blazer/adapters/sql_adapter.rb b/lib/blazer/adapters/sql_adapter.rb
index 25bbe203..94c828c7 100644
--- a/lib/blazer/adapters/sql_adapter.rb
+++ b/lib/blazer/adapters/sql_adapter.rb
@@ -155,7 +155,13 @@ module Blazer
if postgresql? || redshift?
execute("SET #{use_transaction? ? "LOCAL " : ""}statement_timeout = #{timeout.to_i * 1000}")
elsif mysql?
- execute("SET max_execution_time = #{timeout.to_i * 1000}")
+ # use send as this method is private in Rails 4.2
+ mariadb = connection_model.connection.send(:mariadb?) rescue false
+ if mariadb
+ execute("SET max_statement_time = #{timeout.to_i * 1000}")
+ else
+ execute("SET max_execution_time = #{timeout.to_i * 1000}")
+ end
else
raise Blazer::TimeoutNotSupported, "Timeout not supported for #{adapter_name} adapter"
end