~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2009-07-10 01:49:29 UTC
  • mto: (1090.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1091.
  • Revision ID: brian@gaz-20090710014929-v8pmvf7woqkld9iv
Cleanup of user_var

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
extern "C" void free_user_var(user_var_entry *entry)
79
79
{
80
 
  char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry));
81
 
  if (entry->value && entry->value != pos)
82
 
    free(entry->value);
83
 
  free((char*) entry);
 
80
  delete entry;
84
81
}
85
82
 
86
83
bool Key_part_spec::operator==(const Key_part_spec& other) const
1896
1893
{
1897
1894
  user_var_entry *entry= NULL;
1898
1895
 
1899
 
  assert(name.length == strlen (name.str));
1900
1896
  entry= (user_var_entry*) hash_search(&user_vars, (unsigned char*) name.str, name.length);
1901
1897
 
1902
1898
  if ((entry == NULL) && create_if_not_exists)
1903
1899
  {
1904
 
    uint32_t size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
1905
1900
    if (!hash_inited(&user_vars))
1906
 
      return 0;
1907
 
    if (!(entry = (user_var_entry*) malloc(size)))
1908
 
      return 0;
1909
 
    entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
1910
 
      extra_size;
1911
 
    entry->name.length=name.length;
1912
 
    entry->value=0;
1913
 
    entry->length=0;
1914
 
    entry->update_query_id=0;
1915
 
    entry->collation.set(NULL, DERIVATION_IMPLICIT);
1916
 
    entry->unsigned_flag= 0;
1917
 
    /*
1918
 
      If we are here, we were called from a SET or a query which sets a
1919
 
      variable. Imagine it is this:
1920
 
      INSERT INTO t SELECT @a:=10, @a:=@a+1.
1921
 
      Then when we have a Item_func_get_user_var (because of the @a+1) so we
1922
 
      think we have to write the value of @a to the binlog. But before that,
1923
 
      we have a Item_func_set_user_var to create @a (@a:=10), in this we mark
1924
 
      the variable as "already logged" (line below) so that it won't be logged
1925
 
      by Item_func_get_user_var (because that's not necessary).
1926
 
    */
1927
 
    entry->used_query_id= query_id;
1928
 
    entry->type=STRING_RESULT;
1929
 
    memcpy(entry->name.str, name.str, name.length+1);
 
1901
      return NULL;
 
1902
    entry= new (nothrow) user_var_entry(name.str, query_id);
 
1903
 
 
1904
    if (entry == NULL)
 
1905
      return NULL;
 
1906
 
1930
1907
    if (my_hash_insert(&user_vars, (unsigned char*) entry))
1931
1908
    {
1932
1909
      assert(1);