rdo-postgres 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/rdo_postgres/driver.c +1 -1
- data/ext/rdo_postgres/params.c +3 -1
- data/lib/rdo/postgres/version.rb +1 -1
- metadata +1 -1
data/ext/rdo_postgres/driver.c
CHANGED
@@ -124,7 +124,7 @@ static VALUE rdo_postgres_driver_quote(VALUE self, VALUE str) {
|
|
124
124
|
"Unable to quote string: connection is not open");
|
125
125
|
}
|
126
126
|
|
127
|
-
char * quoted = malloc(sizeof(char) * RSTRING_LEN(str) *
|
127
|
+
char * quoted = malloc(sizeof(char) * RSTRING_LEN(str) * 2 + 1);
|
128
128
|
PQescapeStringConn(driver->conn_ptr, quoted,
|
129
129
|
RSTRING_PTR(str), RSTRING_LEN(str), NULL);
|
130
130
|
|
data/ext/rdo_postgres/params.c
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
#include "params.h"
|
9
9
|
#include <stdlib.h>
|
10
10
|
#include <string.h>
|
11
|
+
#include <math.h>
|
11
12
|
|
12
13
|
/** Get the strlen of the marker (e.g. $2) based on its index */
|
13
14
|
#define RDO_PG_MARKER_LEN(n) (n >= 100 ? 4 : (n >= 10 ? 3 : 2))
|
@@ -20,7 +21,8 @@
|
|
20
21
|
* This function is deliberately not broken apart, since it needs to be extremely fast.
|
21
22
|
*/
|
22
23
|
char * rdo_postgres_params_inject_markers(char * stmt) {
|
23
|
-
|
24
|
+
int len = strlen(stmt);
|
25
|
+
char * buf = malloc(sizeof(char) * len ? (len * (floor(log(len)) + 2)) : 0);
|
24
26
|
char * s = stmt;
|
25
27
|
char * b = buf;
|
26
28
|
int n = 0;
|
data/lib/rdo/postgres/version.rb
CHANGED