~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-08-08 01:03:09 UTC
  • mto: This revision was merged to the branch mainline in revision 1697.
  • Revision ID: brian@gaz-20100808010309-g4shoodkzo9oxbke
Remove the hash in session, for a boost based one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
extern pthread_key_t THR_Session;
74
74
extern pthread_key_t THR_Mem_root;
75
75
 
76
 
 
77
 
/****************************************************************************
78
 
** User variables
79
 
****************************************************************************/
80
 
static unsigned char *get_var_key(user_var_entry *entry, size_t *length, bool)
81
 
{
82
 
  *length= entry->name.length;
83
 
  return (unsigned char*) entry->name.str;
84
 
}
85
 
 
86
 
static void free_user_var(user_var_entry *entry)
87
 
{
88
 
  delete entry;
89
 
}
90
 
 
91
76
bool Key_part_spec::operator==(const Key_part_spec& other) const
92
77
{
93
78
  return length == other.length &&
259
244
 
260
245
  /* Initialize sub structures */
261
246
  memory::init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
262
 
  hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
263
 
            (hash_get_key) get_var_key,
264
 
            (hash_free_key) free_user_var, 0);
265
247
 
266
248
  substitute_null_with_insert_id = false;
267
249
  thr_lock_info_init(&lock_info); /* safety: will be reset after start */
333
315
    transaction_services.rollbackTransaction(this, true);
334
316
    xid_cache_delete(&transaction.xid_state);
335
317
  }
336
 
  hash_free(&user_vars);
 
318
 
 
319
  for (UserVars::iterator iter= user_vars.begin();
 
320
       iter != user_vars.end();
 
321
       iter++)
 
322
  {
 
323
    user_var_entry *entry= (*iter).second;
 
324
    delete entry;
 
325
  }
 
326
  user_vars.clear();
 
327
 
 
328
 
337
329
  close_temporary_tables();
338
330
 
339
331
  if (global_read_lock)
1720
1712
user_var_entry *Session::getVariable(LEX_STRING &name, bool create_if_not_exists)
1721
1713
{
1722
1714
  user_var_entry *entry= NULL;
 
1715
  UserVarsRange ppp= user_vars.equal_range(std::string(name.str, name.length));
1723
1716
 
1724
 
  entry= (user_var_entry*) hash_search(&user_vars, (unsigned char*) name.str, name.length);
 
1717
  for (UserVars::iterator iter= ppp.first;
 
1718
         iter != ppp.second; ++iter)
 
1719
  {
 
1720
    entry= (*iter).second;
 
1721
  }
1725
1722
 
1726
1723
  if ((entry == NULL) && create_if_not_exists)
1727
1724
  {
1728
 
    if (!hash_inited(&user_vars))
1729
 
      return NULL;
1730
1725
    entry= new (nothrow) user_var_entry(name.str, query_id);
1731
1726
 
1732
1727
    if (entry == NULL)
1733
1728
      return NULL;
1734
1729
 
1735
 
    if (my_hash_insert(&user_vars, (unsigned char*) entry))
 
1730
    std::pair<UserVars::iterator, bool> returnable= user_vars.insert(make_pair(std::string(name.str, name.length), entry));
 
1731
 
 
1732
    if (not returnable.second)
1736
1733
    {
1737
 
      assert(1);
1738
1734
      delete entry;
1739
 
      return 0;
 
1735
      return NULL;
1740
1736
    }
1741
 
 
1742
1737
  }
1743
1738
 
1744
1739
  return entry;