diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/csv/ha_tina.cc | 34 | ||||
-rw-r--r-- | storage/myisammrg/ha_myisammrg.cc | 15 |
2 files changed, 32 insertions, 17 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index d7710ad3c9b..dad28a74af6 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -548,7 +548,10 @@ int ha_tina::encode_quote(byte *buf) in the code. */ if ((*field)->is_null()) - ptr= end_ptr= 0; + { + buffer.append(STRING_WITH_LEN("\"\",")); + continue; + } else { (*field)->val_str(&attribute,&attribute); @@ -649,6 +652,7 @@ int ha_tina::find_current_row(byte *buf) off_t end_offset, curr_offset= current_position; int eoln_len; my_bitmap_map *org_bitmap; + int error; DBUG_ENTER("ha_tina::find_current_row"); /* @@ -662,23 +666,23 @@ int ha_tina::find_current_row(byte *buf) /* Avoid asserts in ::store() for columns that are not going to be updated */ org_bitmap= dbug_tmp_use_all_columns(table, table->write_set); + error= HA_ERR_CRASHED_ON_USAGE; + + memset(buf, 0, table->s->null_bytes); for (Field **field=table->field ; *field ; field++) { buffer.length(0); - if (file_buff->get_value(curr_offset) == '"') + if (curr_offset < end_offset && + file_buff->get_value(curr_offset) == '"') curr_offset++; // Incrementpast the first quote else - { - dbug_tmp_restore_column_map(table->write_set, org_bitmap); - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - } - for(;curr_offset != end_offset; curr_offset++) + goto err; + for(;curr_offset < end_offset; curr_offset++) { // Need to convert line feeds! if (file_buff->get_value(curr_offset) == '"' && - (((file_buff->get_value(curr_offset + 1) == ',') && - (file_buff->get_value(curr_offset + 2) == '"')) || + ((file_buff->get_value(curr_offset + 1) == ',') || (curr_offset == end_offset -1 ))) { curr_offset+= 2; // Move past the , and the " @@ -708,10 +712,7 @@ int ha_tina::find_current_row(byte *buf) we are working with a damaged file. */ if (curr_offset == end_offset - 1) - { - dbug_tmp_restore_column_map(table->write_set, org_bitmap); - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); - } + goto err; buffer.append(file_buff->get_value(curr_offset)); } } @@ -719,11 +720,12 @@ int ha_tina::find_current_row(byte *buf) (*field)->store(buffer.ptr(), buffer.length(), system_charset_info); } next_position= end_offset + eoln_len; - /* Maybe use \N for null? */ - memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */ + error= 0; + +err: dbug_tmp_restore_column_map(table->write_set, org_bitmap); - DBUG_RETURN(0); + DBUG_RETURN(error); } /* diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index db66c9d6442..21a0e265a64 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -312,9 +312,22 @@ void ha_myisammrg::info(uint flag) if (flag & HA_STATUS_CONST) { if (table->s->key_parts && info.rec_per_key) + { +#ifdef HAVE_purify + /* + valgrind may be unhappy about it, because optimizer may access values + between file->keys and table->key_parts, that will be uninitialized. + It's safe though, because even if opimizer will decide to use a key + with such a number, it'll be an error later anyway. + */ + bzero((char*) table->key_info[0].rec_per_key, + sizeof(table->key_info[0].rec_per_key) * table->key_parts); +#endif memcpy((char*) table->key_info[0].rec_per_key, (char*) info.rec_per_key, - sizeof(table->key_info[0].rec_per_key)*table->s->key_parts); + sizeof(table->key_info[0].rec_per_key) * + min(file->keys, table->s->key_parts)); + } } } |