diff options
author | unknown <knielsen@mysql.com> | 2006-06-22 16:42:50 +0200 |
---|---|---|
committer | unknown <knielsen@mysql.com> | 2006-06-22 16:42:50 +0200 |
commit | ee99794ac228edf10fca2a972fb33734f7caf77f (patch) | |
tree | 0d04a669f70251865e4db969a401ca732fa193ba /sql/sql_class.cc | |
parent | 6526200a19a400236a41dcc5b1ea3a19c340c5fd (diff) | |
download | mariadb-git-ee99794ac228edf10fca2a972fb33734f7caf77f.tar.gz |
BUG#20549: Fix missing memory initialization.
Some values were not initialized, causing Valgrind errors (and potential
random bugs):
- NDB binlog thread thd->variables.pseudo_thread_id.
- Table null bits.
- Field bytes for columns with NULL values.
sql/ha_ndbcluster_binlog.cc:
Fix initialization of thd->variables.pseudo_thread_id.
Change double alloc_root() call to multi_alloc_root().
Fix missing initialization of null bits.
sql/sql_class.cc:
Do not read from the supplied record for NULL values, use the default
value record instead.
Otherwise we will get Valgrind errors about uninitialised values written
to binlog, as NDB does not initialize the memory in records for NULL
fields.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0ede042da17..1c7d00a5fe1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2475,15 +2475,19 @@ my_size_t THD::pack_row(TABLE *table, MY_BITMAP const* cols, byte *row_data, int n_null_bytes= table->s->null_bytes; byte *ptr; uint i; - my_ptrdiff_t const offset= (my_ptrdiff_t) (record - (byte*) - table->record[0]); + my_ptrdiff_t const rec_offset= record - table->record[0]; + my_ptrdiff_t const def_offset= table->s->default_values - table->record[0]; memcpy(row_data, record, n_null_bytes); ptr= row_data+n_null_bytes; for (i= 0 ; (field= *p_field) ; i++, p_field++) { if (bitmap_is_set(cols,i)) + { + my_ptrdiff_t const offset= + field->is_null(rec_offset) ? def_offset : rec_offset; ptr= (byte*)field->pack((char *) ptr, field->ptr + offset); + } } return (static_cast<my_size_t>(ptr - row_data)); } |