Commit 13f55aac authored by Michael Widenius's avatar Michael Widenius

A bit better fix for tmp-table problem

Fixed reference to not initialized memory detected by valgrind

sql/sql_select.cc:
  A bit better fix for tmp-table problem:
  Use only dynamic_record format for group by and distinct.
storage/maria/ma_create.c:
  DYNAMIC_RECORD format doesn't pack VARCHAR fields.
  This change fixes a non-fatal uninitialized memory copy.
parent 5831ddcf
......@@ -11014,16 +11014,17 @@ static bool create_internal_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
The STATIC_RECORD format is the fastest one, because it's so simple,
so we use this by default for short rows.
BLOCK_RECORD caches both row and data, so this is generally faster than
DYNAMIC_RECORD. The one exception is when we write to tmp table
(no updates == no sum fields) in which case BLOCK RECORD is slower as
DYNAMIC_RECORD. The one exception is when we write to tmp table and
want to use keys for duplicate elimination as with BLOCK RECORD
we first write the row, then check for key conflicts and then we have to
delete the row.
delete the row. The cases when this can happen is when there is
a group by and no sum functions or if distinct is used.
*/
if ((error= maria_create(share->table_name.str,
(share->reclength < 64 &&
!share->blob_fields ? STATIC_RECORD :
!param->sum_func_count ? DYNAMIC_RECORD :
BLOCK_RECORD),
((!param->sum_func_count && table->group) ||
table->distinct) ? DYNAMIC_RECORD : BLOCK_RECORD),
share->keys, &keydef,
(uint) (param->recinfo-param->start_recinfo),
param->start_recinfo,
......
......@@ -204,7 +204,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
pack_reclength++;
not_block_record_extra_length++;
max_field_lengths++;
packed++;
if (datafile_type != DYNAMIC_RECORD)
packed++;
column->fill_length= 1;
options|= HA_OPTION_NULL_FIELDS; /* Use ma_checksum() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment