aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-07-28 19:03:21 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-07-28 19:03:21 -0400
commitd5d93dc5d985c8411bf9336279a996d01abdbde9 (patch)
tree0ba0321cd4bac968aea3815b540a89f2316ba582
parent08b465f3f26b209965437982040f99408f4dcb19 (diff)
downloadmysqlerl-d5d93dc5d985c8411bf9336279a996d01abdbde9.tar.gz
mysqlerl-d5d93dc5d985c8411bf9336279a996d01abdbde9.zip
Assume we're getting one value at a time, and the erlang half of
things will handle multi-assignment.
-rw-r--r--src/mysqlerl.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/mysqlerl.c b/src/mysqlerl.c
index 9aea7c6..1942708 100644
--- a/src/mysqlerl.c
+++ b/src/mysqlerl.c
@@ -293,17 +293,10 @@ handle_param_query(ETERM *msg)
for (i = 0, tmp = params;
(p = erl_hd(tmp)) != NULL && i < 1000;
i++, tmp = erl_tl(tmp)) {
- ETERM *type, *values, *v;
+ ETERM *type, *value;
type = erl_element(1, p);
- values = erl_element(2, p);
- v = erl_hd(values);
-
- fprintf(stderr, "type: ");
- erl_print_term(stderr, type);
- fprintf(stderr, "\nv: ");
- erl_print_term(stderr, values);
- fprintf(stderr, "\n");
+ value = erl_element(2, p);
if (ERL_IS_TUPLE(type)) {
ETERM *t_type, *t_size;
@@ -320,27 +313,27 @@ handle_param_query(ETERM *msg)
bind[i].buffer_type = MYSQL_TYPE_LONG;
*bind[i].length = bind[i].buffer_length * sizeof(int);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(int));
+ memcpy(bind[i].buffer, value, sizeof(int));
} else if (strncmp(t, DECIMAL_SQL, strlen(DECIMAL_SQL)) == 0) {
bind[i].buffer_type = MYSQL_TYPE_STRING;
*bind[i].length = bind[i].buffer_length * sizeof(char *);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(char));
+ memcpy(bind[i].buffer, value, sizeof(char));
} else if (strncmp(t, FLOAT_SQL, strlen(FLOAT_SQL)) == 0) {
bind[i].buffer_type = MYSQL_TYPE_FLOAT;
*bind[i].length = bind[i].buffer_length * sizeof(float);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(float));
+ memcpy(bind[i].buffer, value, sizeof(float));
} else if (strncmp(t, CHAR_SQL, strlen(CHAR_SQL)) == 0) {
bind[i].buffer_type = MYSQL_TYPE_STRING;
*bind[i].length = bind[i].buffer_length * sizeof(char *);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(char));
+ memcpy(bind[i].buffer, value, sizeof(char));
} else if (strncmp(t, VARCHAR_SQL, strlen(VARCHAR_SQL)) == 0) {
bind[i].buffer_type = MYSQL_TYPE_BLOB;
*bind[i].length = bind[i].buffer_length * sizeof(char *);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(char));
+ memcpy(bind[i].buffer, value, sizeof(char));
} else {
logmsg("ERROR: Unknown sized type: {%s, %d}", t,
bind[i].buffer_length);
@@ -355,12 +348,12 @@ handle_param_query(ETERM *msg)
bind[i].buffer_type = MYSQL_TYPE_TIMESTAMP;
*bind[i].length = sizeof(int);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(MYSQL_TYPE_TIMESTAMP));
+ memcpy(bind[i].buffer, value, sizeof(MYSQL_TYPE_TIMESTAMP));
} else if (strncmp(t, INTEGER_SQL, strlen(INTEGER_SQL)) == 0) {
bind[i].buffer_type = MYSQL_TYPE_LONG;
*bind[i].length = sizeof(int);
bind[i].buffer = malloc(*bind[i].length);
- memcpy(bind[i].buffer, v, sizeof(int));
+ memcpy(bind[i].buffer, value, sizeof(int));
} else {
logmsg("ERROR: Unknown type: %s", t);
exit(3);
@@ -368,14 +361,14 @@ handle_param_query(ETERM *msg)
}
bind[i].is_null = malloc(sizeof(int));
- if (ERL_IS_ATOM(v)
- && strncmp((char *)ERL_ATOM_PTR(v),
+ if (ERL_IS_ATOM(value)
+ && strncmp((char *)ERL_ATOM_PTR(value),
NULL_SQL, strlen(NULL_SQL)) == 0)
memcpy(bind[i].is_null, &TRUTHY, sizeof(int));
else
memcpy(bind[i].is_null, &FALSY, sizeof(int));
- erl_free_term(values);
+ erl_free_term(value);
erl_free_term(type);
}
erl_free_term(params);