Bug #37613 user_var_entry allocations do not use the user_var_entry constructor
Submitted: 24 Jun 2008 18:46 Modified: 24 Jun 2008 20:29
Reporter: Mark Callaghan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0.37, 5.0, 5.1, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any
Tags: get_variable, qc, user_var_entry

[24 Jun 2008 18:46] Mark Callaghan
Description:
static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
				    bool create_if_not_exists)
{
  user_var_entry *entry;

user_var_entry is a class with a constructor. get_variable uses my_malloc to allocate it, preventing the constructor from being called. Fortunately, the constructor is empty. If nothing else, add a comment to the constructor indicating that this is done.

---
 
From get_variable()
...
 if (!(entry = (user_var_entry*) hash_search(hash, (byte*) name.str,
					      name.length)) &&
      create_if_not_exists)
  {
    uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
    if (!hash_inited(hash))
      return 0;
    if (!(entry = (user_var_entry*) my_malloc(size,MYF(MY_WME))))
      return 0;
    entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
      extra_size;
    entry->name.length=name.length;
    entry->value=0;
    entry->length=0;
    entry->update_query_id=0;
    entry->collation.set(NULL, DERIVATION_IMPLICIT);
    entry->unsigned_flag= 0;
    entry->may_be_set= 0;
    /*

How to repeat:
NA
[24 Jun 2008 20:29] Sveta Smirnova
Thank you for the report.

Verified as described.