dbd/mysql/statement.c

changeset 46
5ba1dd988961
parent 45
7c968f66bccd
equal deleted inserted replaced
45:7c968f66bccd 46:5ba1dd988961
344 for (i = 0; i < column_count; i++) { 344 for (i = 0; i < column_count; i++) {
345 lua_push_type_t lua_push = mysql_to_lua_push(fields[i].type); 345 lua_push_type_t lua_push = mysql_to_lua_push(fields[i].type);
346 const char *name = fields[i].name; 346 const char *name = fields[i].name;
347 347
348 if (bind[i].buffer == NULL) { 348 if (bind[i].buffer == NULL) {
349 char *buffer = (char *)malloc(real_length[i]); 349 char *buffer = (char *)calloc(real_length[i]+1, sizeof(char));
350 memset(buffer, 0, real_length[i]);
351
352 bind[i].buffer = buffer; 350 bind[i].buffer = buffer;
353 bind[i].buffer_length = real_length[i]; 351 bind[i].buffer_length = real_length[i];
354 mysql_stmt_fetch_column(statement->stmt, bind, i, 0); 352 mysql_stmt_fetch_column(statement->stmt, &bind[i], i, 0);
355 } 353 }
356 354
357 if (lua_push == LUA_PUSH_NIL) { 355 if (lua_push == LUA_PUSH_NIL) {
358 if (named_columns) { 356 if (named_columns) {
359 LUA_PUSH_ATTRIB_NIL(name); 357 LUA_PUSH_ATTRIB_NIL(name);

mercurial