From 864cf0f29140679cfdb04d1f3ed755e608a6fe99 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 20 Aug 2010 09:36:15 -0700 Subject: [PATCH] exposing client flags --- Rakefile | 2 ++ ext/mysql2/client.c | 8 ++++---- lib/mysql2/client.rb | 3 ++- spec/spec_helper.rb | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 7a1c103..df610fe 100644 --- a/Rakefile +++ b/Rakefile @@ -32,6 +32,8 @@ end Spec::Rake::SpecTask.new('spec') do |t| t.spec_files = FileList['spec/'] t.spec_opts << '--options' << 'spec/spec.opts' + t.verbose = true + t.warning = true end task :default => :spec diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index f4a43f9..d779205 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -150,7 +150,7 @@ static VALUE allocate(VALUE klass) { return obj; } -static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket) { +static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags) { struct nogvl_connect_args args; GET_CLIENT(self) @@ -161,7 +161,7 @@ static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE po args.passwd = NIL_P(pass) ? NULL : StringValuePtr(pass); args.db = NIL_P(database) ? NULL : StringValuePtr(database); args.mysql = client; - args.client_flag = 0; + args.client_flag = NUM2INT(flags); if (rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0) == Qfalse) { // unable to connect @@ -523,7 +523,7 @@ void init_mysql2_client() { rb_define_private_method(cMysql2Client, "charset_name=", set_charset_name, 1); rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); rb_define_private_method(cMysql2Client, "init_connection", init_connection, 0); - rb_define_private_method(cMysql2Client, "connect", rb_connect, 6); + rb_define_private_method(cMysql2Client, "connect", rb_connect, 7); intern_encoding_from_charset = rb_intern("encoding_from_charset"); @@ -538,4 +538,4 @@ void init_mysql2_client() { intern_error_number_eql = rb_intern("error_number="); intern_sql_state_eql = rb_intern("sql_state="); -} \ No newline at end of file +} diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb index 81d08bc..3cd3aa8 100644 --- a/lib/mysql2/client.rb +++ b/lib/mysql2/client.rb @@ -30,8 +30,9 @@ module Mysql2 port = opts[:port] || 3306 database = opts[:database] socket = opts[:socket] + flags = 0 - connect user, pass, host, port, database, socket + connect user, pass, host, port, database, socket, flags end def self.default_query_options diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 49c3b78..39da1e4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ # encoding: UTF-8 -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +require 'rubygems' require 'mysql2' require 'timeout' @@ -64,4 +63,4 @@ Spec::Runner.configure do |config| ) ] end -end \ No newline at end of file +end