jrmey-mysqlplus 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +49 -0
- data/Rakefile +52 -0
- data/TODO_LIST +12 -0
- data/ext/error_const.h +539 -0
- data/ext/extconf.rb +133 -0
- data/ext/mysql.c +2828 -0
- data/lib/mysqlplus.rb +23 -0
- data/mysqlplus.gemspec +30 -0
- data/test/RUN_ALL_TESTS.RB +9 -0
- data/test/all_hashes_test.rb +37 -0
- data/test/async_query_with_block_test.rb +7 -0
- data/test/c_threaded_test.rb +36 -0
- data/test/connect_failure2_test.rb +22 -0
- data/test/connect_failure_test.rb +17 -0
- data/test/create_test_db.rb +22 -0
- data/test/evented_test.rb +31 -0
- data/test/gc_benchmark_test.rb +40 -0
- data/test/many_requests_test.rb +6 -0
- data/test/native_threaded_test.rb +36 -0
- data/test/out_of_sync_test.rb +34 -0
- data/test/query_with_result_false_test.rb +47 -0
- data/test/reconnected_test.rb +18 -0
- data/test/test_helper.rb +198 -0
- data/test/threaded_sequel_test.rb +24 -0
- metadata +89 -0
data/ext/extconf.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
def exec_command(command, flag_raise=false)
|
4
|
+
output = `#{command}`
|
5
|
+
return output.chomp if $? == 0
|
6
|
+
msg = "failed: #{command}"
|
7
|
+
raise msg if flag_raise
|
8
|
+
die msg
|
9
|
+
end
|
10
|
+
|
11
|
+
def die(message)
|
12
|
+
$stderr.puts "*** ERROR: #{message}"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if /mswin32/ =~ RUBY_PLATFORM
|
17
|
+
inc, lib = dir_config('mysql')
|
18
|
+
#exit 1 unless have_library("libmysql")
|
19
|
+
have_library("libmysql") or die "can't find libmysql."
|
20
|
+
elsif mc = with_config('mysql-config') then
|
21
|
+
mc = 'mysql_config' if mc == true
|
22
|
+
#cflags = `#{mc} --cflags`.chomp
|
23
|
+
#exit 1 if $? != 0
|
24
|
+
cflags = exec_command("#{mc} --cflags")
|
25
|
+
#libs = `#{mc} --libs`.chomp
|
26
|
+
#exit 1 if $? != 0
|
27
|
+
libs = exec_command("#{mc} --libs")
|
28
|
+
$CPPFLAGS += ' ' + cflags
|
29
|
+
$libs = libs + " " + $libs
|
30
|
+
else
|
31
|
+
puts "Trying to detect MySQL configuration with mysql_config command..."
|
32
|
+
begin
|
33
|
+
cflags = libs = nil
|
34
|
+
|
35
|
+
dirs = ENV['PATH'].split(':') + %w[
|
36
|
+
/opt
|
37
|
+
/opt/local
|
38
|
+
/opt/local/mysql
|
39
|
+
/opt/local/lib/mysql5
|
40
|
+
/usr
|
41
|
+
/usr/local
|
42
|
+
/usr/local/mysql
|
43
|
+
/usr/local/mysql-*
|
44
|
+
/usr/local/lib/mysql5
|
45
|
+
].map{|dir| "#{dir}/bin" }
|
46
|
+
|
47
|
+
GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5}"
|
48
|
+
|
49
|
+
if /mswin32/ =~ RUBY_PLATFORM
|
50
|
+
inc, lib = dir_config('mysql')
|
51
|
+
exit 1 unless have_library("libmysql")
|
52
|
+
elsif mc = (with_config('mysql-config') || Dir[GLOB].first) then
|
53
|
+
mc = Dir[GLOB].first if mc == true
|
54
|
+
puts "Succeeded to detect MySQL configuration: #{mc}"
|
55
|
+
cflags = `#{mc} --cflags`.chomp
|
56
|
+
exit 1 if $? != 0
|
57
|
+
libs = `#{mc} --libs`.chomp
|
58
|
+
exit 1 if $? != 0
|
59
|
+
$CPPFLAGS += ' ' + cflags
|
60
|
+
$libs = libs + " " + $libs
|
61
|
+
else
|
62
|
+
puts "Failed to detect MySQL configuration with mysql_config command."
|
63
|
+
puts "Trying to detect MySQL client library..."
|
64
|
+
inc, lib = dir_config('mysql', '/usr/local')
|
65
|
+
libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
|
66
|
+
while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
|
67
|
+
#exit 1 if libs.empty?
|
68
|
+
!libs.empty? or die "can't find mysql client library."
|
69
|
+
have_library(libs.shift)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
have_func('mysql_ssl_set')
|
77
|
+
have_func('rb_str_set_len')
|
78
|
+
|
79
|
+
if have_header('mysql.h') then
|
80
|
+
src = "#include <errmsg.h>\n#include <mysqld_error.h>\n"
|
81
|
+
elsif have_header('mysql/mysql.h') then
|
82
|
+
src = "#include <mysql/errmsg.h>\n#include <mysql/mysqld_error.h>\n"
|
83
|
+
else
|
84
|
+
#exit 1
|
85
|
+
die "can't find 'mysql.h'."
|
86
|
+
end
|
87
|
+
|
88
|
+
# check for 1.9
|
89
|
+
if have_func('rb_thread_blocking_region') and have_macro('RUBY_UBF_IO', 'ruby.h')
|
90
|
+
$CFLAGS += " -DHAVE_TBR "
|
91
|
+
$CPPFLAGS << " -DHAVE_TBR "
|
92
|
+
end
|
93
|
+
|
94
|
+
# make mysql constant
|
95
|
+
File.open("conftest.c", "w") do |f|
|
96
|
+
f.puts src
|
97
|
+
end
|
98
|
+
if defined? cpp_command then
|
99
|
+
cpp = Config.expand(cpp_command(''))
|
100
|
+
else
|
101
|
+
cpp = Config.expand sprintf(CPP, $CPPFLAGS, $CFLAGS, '')
|
102
|
+
end
|
103
|
+
if /mswin32/ =~ RUBY_PLATFORM && !/-E/.match(cpp)
|
104
|
+
cpp << " -E"
|
105
|
+
end
|
106
|
+
#unless system "#{cpp} > confout" then
|
107
|
+
# exit 1
|
108
|
+
#end
|
109
|
+
exec_command("#{cpp} > confout")
|
110
|
+
File.unlink "conftest.c"
|
111
|
+
|
112
|
+
error_syms = []
|
113
|
+
IO.foreach('confout') do |l|
|
114
|
+
next unless l =~ /errmsg\.h|mysqld_error\.h/
|
115
|
+
fn = l.split(/\"/)[1]
|
116
|
+
IO.foreach(fn) do |m|
|
117
|
+
if m =~ /^#define\s+([CE]R_[0-9A-Z_]+)/ then
|
118
|
+
error_syms << $1
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
File.unlink 'confout'
|
123
|
+
error_syms.uniq!
|
124
|
+
|
125
|
+
File.open('error_const.h', 'w') do |f|
|
126
|
+
error_syms.each do |s|
|
127
|
+
f.puts " rb_define_mysql_const(#{s});"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
$CPPFLAGS += " -DRUBY19" if RUBY_VERSION =~ /1.9/
|
132
|
+
|
133
|
+
create_makefile("mysql")
|