57 |
57 |
58 MYSQL_BIND *bind = NULL; |
58 MYSQL_BIND *bind = NULL; |
59 MYSQL_RES *metadata = NULL; |
59 MYSQL_RES *metadata = NULL; |
60 |
60 |
61 char *error_message = NULL; |
61 char *error_message = NULL; |
|
62 char *errstr = NULL; |
62 |
63 |
63 int p; |
64 int p; |
64 |
65 |
65 if (!statement->stmt) { |
66 if (!statement->stmt) { |
66 lua_pushboolean(L, 0); |
67 lua_pushboolean(L, 0); |
70 |
71 |
71 expected_params = mysql_stmt_param_count(statement->stmt); |
72 expected_params = mysql_stmt_param_count(statement->stmt); |
72 |
73 |
73 if (expected_params != num_bind_params) { |
74 if (expected_params != num_bind_params) { |
74 /* |
75 /* |
75 * mysql_stmt_bind_param does not handle this conndition, |
76 * mysql_stmt_bind_param does not handle this condition, |
76 * and the client library will segfault if these do no match |
77 * and the client library will segfault if these do no match |
77 */ |
78 */ |
78 lua_pushboolean(L, 0); |
79 lua_pushboolean(L, 0); |
79 lua_pushfstring(L, DBI_ERR_PARAM_MISCOUNT, expected_params, num_bind_params); |
80 lua_pushfstring(L, DBI_ERR_PARAM_MISCOUNT, expected_params, num_bind_params); |
80 return 2; |
81 return 2; |
130 bind[i].buffer = (char *)str; |
132 bind[i].buffer = (char *)str; |
131 bind[i].length = str_len; |
133 bind[i].length = str_len; |
132 break; |
134 break; |
133 |
135 |
134 default: |
136 default: |
135 error_message = DBI_ERR_BINDING_UNKNOWN; |
137 snprintf(err, sizeof(err)-1, DBI_ERR_BINDING_TYPE_ERR, lua_typename(L, type)); |
|
138 errstr = err; |
|
139 error_message = DBI_ERR_BINDING_PARAMS; |
136 goto cleanup; |
140 goto cleanup; |
137 } |
141 } |
138 } |
142 } |
139 |
143 |
140 if (mysql_stmt_bind_param(statement->stmt, bind)) { |
144 if (mysql_stmt_bind_param(statement->stmt, bind)) { |