exposing client flags

This commit is contained in:
Aaron Patterson 2010-08-20 09:36:15 -07:00
parent 4935931431
commit 864cf0f291
4 changed files with 10 additions and 8 deletions

View File

@ -32,6 +32,8 @@ end
Spec::Rake::SpecTask.new('spec') do |t| Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/'] t.spec_files = FileList['spec/']
t.spec_opts << '--options' << 'spec/spec.opts' t.spec_opts << '--options' << 'spec/spec.opts'
t.verbose = true
t.warning = true
end end
task :default => :spec task :default => :spec

View File

@ -150,7 +150,7 @@ static VALUE allocate(VALUE klass) {
return obj; 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; struct nogvl_connect_args args;
GET_CLIENT(self) 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.passwd = NIL_P(pass) ? NULL : StringValuePtr(pass);
args.db = NIL_P(database) ? NULL : StringValuePtr(database); args.db = NIL_P(database) ? NULL : StringValuePtr(database);
args.mysql = client; 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) { if (rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0) == Qfalse) {
// unable to connect // 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, "charset_name=", set_charset_name, 1);
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); 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, "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"); intern_encoding_from_charset = rb_intern("encoding_from_charset");

View File

@ -30,8 +30,9 @@ module Mysql2
port = opts[:port] || 3306 port = opts[:port] || 3306
database = opts[:database] database = opts[:database]
socket = opts[:socket] socket = opts[:socket]
flags = 0
connect user, pass, host, port, database, socket connect user, pass, host, port, database, socket, flags
end end
def self.default_query_options def self.default_query_options

View File

@ -1,7 +1,6 @@
# encoding: UTF-8 # 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 'mysql2'
require 'timeout' require 'timeout'