oedipus 0.0.11 → 0.0.12
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/ext/oedipus/lexing.h +3 -0
- data/ext/oedipus/oedipus.c +22 -13
- data/lib/oedipus/version.rb +1 -1
- data/spec/integration/connection_spec.rb +4 -0
- metadata +7 -7
data/ext/oedipus/lexing.h
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
* See LICENSE file for details.
|
8
8
|
*/
|
9
9
|
|
10
|
+
/*! Scans the entire string pointed to by src into the string pointed to by dest, advancing both pointers */
|
11
|
+
int odp_scan_move_pointers(char ** src, char ** dest, long len);
|
12
|
+
|
10
13
|
/*! Consume input from the string pointed to by sql_ptr, into the string pointed to by dest_ptr, until stop is reached (inclusive) */
|
11
14
|
int odp_scan_until_char(char stop, char ** sql_ptr, char ** dest_ptr, unsigned long len);
|
12
15
|
|
data/ext/oedipus/oedipus.c
CHANGED
@@ -190,6 +190,16 @@ static void odp_free(OdpMysql * conn) {
|
|
190
190
|
free(conn);
|
191
191
|
}
|
192
192
|
|
193
|
+
int odp_scan_move_pointers(char ** src, char ** dest, long len) {
|
194
|
+
char * end = *src + len;
|
195
|
+
|
196
|
+
for (; *src < end; ++(*src)) {
|
197
|
+
*((*dest)++) = **src;
|
198
|
+
}
|
199
|
+
|
200
|
+
return 1;
|
201
|
+
}
|
202
|
+
|
193
203
|
static VALUE odp_replace_bind_values(OdpMysql * conn, VALUE sql, VALUE * bind_values, int num_values) {
|
194
204
|
// FIXME: Refactor this whole method, somehow... use a struct instead of a gazillion variables, so other functions can be called
|
195
205
|
char * sql_str;
|
@@ -217,7 +227,7 @@ static VALUE odp_replace_bind_values(OdpMysql * conn, VALUE sql, VALUE * bind_va
|
|
217
227
|
}
|
218
228
|
|
219
229
|
{
|
220
|
-
char escaped_sql_str[escaped_sql_len];
|
230
|
+
char escaped_sql_str[escaped_sql_len]; // FIXME: Possibly use the heap
|
221
231
|
char * sql_end;
|
222
232
|
char * dest;
|
223
233
|
|
@@ -226,33 +236,32 @@ static VALUE odp_replace_bind_values(OdpMysql * conn, VALUE sql, VALUE * bind_va
|
|
226
236
|
|
227
237
|
for (i = 0; i < num_values; ++i) {
|
228
238
|
char * str = str_values[i];
|
229
|
-
|
230
|
-
long pos = 0;
|
239
|
+
long len = strlen(str);
|
231
240
|
|
232
241
|
if (!(odp_scan_until_marker(&sql_str, &dest, sql_end - sql_str))) {
|
233
242
|
break;
|
234
243
|
}
|
235
244
|
|
236
245
|
if (!(ODP_KIND_OF_P(bind_values[i], rb_cNumeric))) {
|
237
|
-
|
238
|
-
char
|
246
|
+
// would prefer to use stack allocation, but it segfaults with larger (megabytes) values
|
247
|
+
char * escaped_str = (char *) malloc(escaped_value_lengths[i]);
|
248
|
+
char * quoted_str = (char *) malloc(escaped_value_lengths[i]);
|
239
249
|
|
240
250
|
mysql_real_escape_string(conn->ptr, escaped_str, str, len);
|
241
251
|
sprintf(quoted_str, "'%s'", escaped_str);
|
242
|
-
|
243
252
|
str = quoted_str;
|
244
|
-
len = strlen(quoted_str);
|
245
|
-
}
|
246
253
|
|
247
|
-
|
248
|
-
|
254
|
+
odp_scan_move_pointers(&str, &dest, strlen(str));
|
255
|
+
|
256
|
+
free(quoted_str);
|
257
|
+
free(escaped_str);
|
258
|
+
} else {
|
259
|
+
odp_scan_move_pointers(&str, &dest, len);
|
249
260
|
}
|
250
261
|
}
|
251
262
|
|
252
263
|
// copy remainder
|
253
|
-
|
254
|
-
*(dest++) = *sql_str;
|
255
|
-
}
|
264
|
+
odp_scan_move_pointers(&sql_str, &dest, sql_end - sql_str);
|
256
265
|
|
257
266
|
return rb_str_new(escaped_sql_str, dest - escaped_sql_str);
|
258
267
|
}
|
data/lib/oedipus/version.rb
CHANGED
@@ -139,5 +139,9 @@ describe Oedipus::Connection do
|
|
139
139
|
it "handles nil" do
|
140
140
|
conn.execute("REPLACE INTO posts_rt (id, title, state, body) VALUES (?, 'question?', 'other?', ?)", 1, nil)
|
141
141
|
end
|
142
|
+
|
143
|
+
it "handles really long strings" do
|
144
|
+
conn.execute("REPLACE INTO posts_rt (id, title, state, body) VALUES (?, 'question?', 'other?', ?)", 1, 'a' * 2_000_000)
|
145
|
+
end
|
142
146
|
end
|
143
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oedipus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &19781180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19781180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake-compiler
|
27
|
-
requirement: &
|
27
|
+
requirement: &19780720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19780720
|
36
36
|
description: ! "== Sphinx 2 Comes to Ruby\n\nOedipus brings full support for Sphinx
|
37
37
|
2 to Ruby:\n\n - real-time indexes (insert, replace, update, delete)\n - faceted
|
38
38
|
search (variations on a base query)\n - multi-queries (multiple queries executed
|
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
segments:
|
113
113
|
- 0
|
114
|
-
hash: -
|
114
|
+
hash: -3179225269925894902
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
segments:
|
122
122
|
- 0
|
123
|
-
hash: -
|
123
|
+
hash: -3179225269925894902
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project: oedipus
|
126
126
|
rubygems_version: 1.8.11
|