~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-08-09 18:04:12 UTC
  • mfrom: (1689.3.7 staging)
  • Revision ID: brian@gaz-20100809180412-olurwh51ojllev6p
Merge in heap conversion, and case insensitive patch, and remove need for
M_HASH in session.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
extern pthread_key_t THR_Session;
75
75
extern pthread_key_t THR_Mem_root;
76
76
 
77
 
 
78
 
/****************************************************************************
79
 
** User variables
80
 
****************************************************************************/
81
 
static unsigned char *get_var_key(user_var_entry *entry, size_t *length, bool)
82
 
{
83
 
  *length= entry->name.length;
84
 
  return (unsigned char*) entry->name.str;
85
 
}
86
 
 
87
 
static void free_user_var(user_var_entry *entry)
88
 
{
89
 
  delete entry;
90
 
}
91
 
 
92
77
bool Key_part_spec::operator==(const Key_part_spec& other) const
93
78
{
94
79
  return length == other.length &&
228
213
  scoreboard_index= -1;
229
214
  dbug_sentry=Session_SENTRY_MAGIC;
230
215
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
231
 
  pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
232
216
 
233
217
  /* Variables with default values */
234
218
  proc_info="login";
260
244
 
261
245
  /* Initialize sub structures */
262
246
  memory::init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
263
 
  hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
264
 
            (hash_get_key) get_var_key,
265
 
            (hash_free_key) free_user_var, 0);
266
247
 
267
248
  substitute_null_with_insert_id = false;
268
249
  lock_info.init(); /* safety: will be reset after start */
334
315
    transaction_services.rollbackTransaction(this, true);
335
316
    xid_cache_delete(&transaction.xid_state);
336
317
  }
337
 
  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
 
338
329
  close_temporary_tables();
339
330
 
340
331
  if (global_read_lock)
378
369
  plugin::EventObserver::deregisterSessionEvents(*this); 
379
370
 
380
371
  /* Ensure that no one is using Session */
381
 
  pthread_mutex_unlock(&LOCK_delete);
382
 
  pthread_mutex_destroy(&LOCK_delete);
 
372
  LOCK_delete.unlock();
383
373
}
384
374
 
385
375
void Session::awake(Session::killed_state state_to_set)
1722
1712
user_var_entry *Session::getVariable(LEX_STRING &name, bool create_if_not_exists)
1723
1713
{
1724
1714
  user_var_entry *entry= NULL;
 
1715
  UserVarsRange ppp= user_vars.equal_range(std::string(name.str, name.length));
1725
1716
 
1726
 
  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
  }
1727
1722
 
1728
1723
  if ((entry == NULL) && create_if_not_exists)
1729
1724
  {
1730
 
    if (!hash_inited(&user_vars))
1731
 
      return NULL;
1732
1725
    entry= new (nothrow) user_var_entry(name.str, query_id);
1733
1726
 
1734
1727
    if (entry == NULL)
1735
1728
      return NULL;
1736
1729
 
1737
 
    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)
1738
1733
    {
1739
 
      assert(1);
1740
1734
      delete entry;
1741
 
      return 0;
 
1735
      return NULL;
1742
1736
    }
1743
 
 
1744
1737
  }
1745
1738
 
1746
1739
  return entry;