mysql2 0.3.18 → 0.4.0

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.
@@ -2,7 +2,13 @@
2
2
  require 'mkmf'
3
3
 
4
4
  def asplode lib
5
- abort "-----\n#{lib} is missing. please check your installation of mysql and try again.\n-----"
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
- libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
70
- while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
71
- exit 1 if libs.empty?
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
- # These gcc style flags are also supported by clang and xcode compilers,
91
- # so we'll use a does-it-work test instead of an is-it-gcc test.
92
- gcc_flags = ' -Wall -funroll-loops'
93
- if try_link('int main() {return 0;}', gcc_flags)
94
- $CFLAGS << gcc_flags
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
- '--dllname', 'libmysql.dll',
112
- '--output-lib', 'libmysql.a',
113
- '--input-def', deffile, libfile
125
+ '--dllname', 'libmysql.dll',
126
+ '--output-lib', 'libmysql.a',
127
+ '--input-def', deffile, libfile
114
128
  end
115
129
  end
116
130
 
@@ -9,4 +9,5 @@ void Init_mysql2() {
9
9
 
10
10
  init_mysql2_client();
11
11
  init_mysql2_result();
12
+ init_mysql2_statement();
12
13
  }
@@ -39,6 +39,7 @@ typedef unsigned int uint;
39
39
  #endif
40
40
 
41
41
  #include <client.h>
42
+ #include <statement.h>
42
43
  #include <result.h>
43
44
  #include <infile.h>
44
45
 
@@ -40,9 +40,9 @@ inline
40
40
  #endif
41
41
  #endif
42
42
  static unsigned int
43
- mysql2_mysql_enc_name_to_rb_hash (str, len)
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 (str, len)
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 (str, len);
157
+ register const unsigned int key = mysql2_mysql_enc_name_to_rb_hash(str, len);
158
158
 
159
- if (key <= MAX_HASH_VALUE && key >= 0)
159
+ if (key <= MAX_HASH_VALUE)
160
160
  {
161
161
  register const char *s = wordlist[key].name;
162
162