mysql2 0.3.18 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/LICENSE +21 -0
- data/README.md +28 -6
- data/examples/threaded.rb +4 -6
- data/ext/mysql2/client.c +124 -126
- data/ext/mysql2/client.h +21 -0
- data/ext/mysql2/extconf.rb +29 -15
- data/ext/mysql2/mysql2_ext.c +1 -0
- data/ext/mysql2/mysql2_ext.h +1 -0
- data/ext/mysql2/mysql_enc_name_to_ruby.h +6 -6
- data/ext/mysql2/result.c +499 -128
- data/ext/mysql2/result.h +9 -3
- data/ext/mysql2/statement.c +454 -0
- data/ext/mysql2/statement.h +22 -0
- data/lib/mysql2/client.rb +24 -1
- data/lib/mysql2/error.rb +9 -21
- data/lib/mysql2/field.rb +4 -0
- data/lib/mysql2/statement.rb +5 -0
- data/lib/mysql2/version.rb +1 -1
- data/lib/mysql2.rb +2 -0
- data/spec/em/em_spec.rb +13 -13
- data/spec/mysql2/client_spec.rb +337 -326
- data/spec/mysql2/error_spec.rb +37 -36
- data/spec/mysql2/result_spec.rb +197 -192
- data/spec/mysql2/statement_spec.rb +598 -0
- data/spec/spec_helper.rb +7 -0
- metadata +15 -46
data/ext/mysql2/extconf.rb
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
require 'mkmf'
|
3
3
|
|
4
4
|
def asplode lib
|
5
|
-
|
5
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
6
|
+
abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----"
|
7
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
8
|
+
abort "-----\n#{lib} is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.\n-----"
|
9
|
+
else
|
10
|
+
abort "-----\n#{lib} is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.\n-----"
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
# 2.0-only
|
@@ -27,9 +33,10 @@ dirs = ENV['PATH'].split(File::PATH_SEPARATOR) + %w[
|
|
27
33
|
/usr/local/mysql
|
28
34
|
/usr/local/mysql-*
|
29
35
|
/usr/local/lib/mysql5*
|
36
|
+
/usr/local/opt/mysql5*
|
30
37
|
].map{|dir| "#{dir}/bin" }
|
31
38
|
|
32
|
-
GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5}"
|
39
|
+
GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}"
|
33
40
|
|
34
41
|
# If the user has provided a --with-mysql-dir argument, we must respect it or fail.
|
35
42
|
inc, lib = dir_config('mysql')
|
@@ -66,11 +73,9 @@ elsif mc = (with_config('mysql-config') || Dir[GLOB].first)
|
|
66
73
|
rpath_dir = libs
|
67
74
|
else
|
68
75
|
inc, lib = dir_config('mysql', '/usr/local')
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
have_library(libs.shift)
|
73
|
-
end
|
76
|
+
|
77
|
+
asplode("mysql client") unless find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
|
78
|
+
|
74
79
|
rpath_dir = lib
|
75
80
|
end
|
76
81
|
|
@@ -87,11 +92,20 @@ end
|
|
87
92
|
asplode h unless have_header h
|
88
93
|
end
|
89
94
|
|
90
|
-
#
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
# This is our wishlist. We use whichever flags work on the host.
|
96
|
+
# TODO: fix statement.c and remove -Wno-declaration-after-statement
|
97
|
+
# TODO: fix gperf mysql_enc_name_to_ruby.h and remove -Wno-missing-field-initializers
|
98
|
+
%w(
|
99
|
+
-Wall
|
100
|
+
-Wextra
|
101
|
+
-Werror
|
102
|
+
-Wno-unused-function
|
103
|
+
-Wno-declaration-after-statement
|
104
|
+
-Wno-missing-field-initializers
|
105
|
+
).select do |flag|
|
106
|
+
try_link('int main() {return 0;}', flag)
|
107
|
+
end.each do |flag|
|
108
|
+
$CFLAGS << ' ' << flag
|
95
109
|
end
|
96
110
|
|
97
111
|
if RUBY_PLATFORM =~ /mswin|mingw/
|
@@ -108,9 +122,9 @@ if RUBY_PLATFORM =~ /mswin|mingw/
|
|
108
122
|
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
|
109
123
|
dlltool = RbConfig::CONFIG['DLLWRAP'].gsub('dllwrap', 'dlltool')
|
110
124
|
sh dlltool, '--kill-at',
|
111
|
-
|
112
|
-
|
113
|
-
|
125
|
+
'--dllname', 'libmysql.dll',
|
126
|
+
'--output-lib', 'libmysql.a',
|
127
|
+
'--input-def', deffile, libfile
|
114
128
|
end
|
115
129
|
end
|
116
130
|
|
data/ext/mysql2/mysql2_ext.c
CHANGED
data/ext/mysql2/mysql2_ext.h
CHANGED
@@ -40,9 +40,9 @@ inline
|
|
40
40
|
#endif
|
41
41
|
#endif
|
42
42
|
static unsigned int
|
43
|
-
mysql2_mysql_enc_name_to_rb_hash
|
43
|
+
mysql2_mysql_enc_name_to_rb_hash(str, len)
|
44
44
|
register const char *str;
|
45
|
-
register unsigned int len;
|
45
|
+
register const unsigned int len;
|
46
46
|
{
|
47
47
|
static const unsigned char asso_values[] =
|
48
48
|
{
|
@@ -83,9 +83,9 @@ __attribute__ ((__gnu_inline__))
|
|
83
83
|
#endif
|
84
84
|
#endif
|
85
85
|
const struct mysql2_mysql_enc_name_to_rb_map *
|
86
|
-
mysql2_mysql_enc_name_to_rb
|
86
|
+
mysql2_mysql_enc_name_to_rb(str, len)
|
87
87
|
register const char *str;
|
88
|
-
register unsigned int len;
|
88
|
+
register const unsigned int len;
|
89
89
|
{
|
90
90
|
enum
|
91
91
|
{
|
@@ -154,9 +154,9 @@ mysql2_mysql_enc_name_to_rb (str, len)
|
|
154
154
|
|
155
155
|
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
156
156
|
{
|
157
|
-
register int key = mysql2_mysql_enc_name_to_rb_hash
|
157
|
+
register const unsigned int key = mysql2_mysql_enc_name_to_rb_hash(str, len);
|
158
158
|
|
159
|
-
if (key <= MAX_HASH_VALUE
|
159
|
+
if (key <= MAX_HASH_VALUE)
|
160
160
|
{
|
161
161
|
register const char *s = wordlist[key].name;
|
162
162
|
|