~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/release_lock.cc

  • Committer: Lee Bieber
  • Date: 2010-11-14 05:18:07 UTC
  • mfrom: (1921.4.12 catalogs)
  • Revision ID: kalebral@gmail.com-20101114051807-p69h40jbsn1byf84
Merge Brian - add execute with no return

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
{
31
31
  drizzled::String *res= args[0]->val_str(&value);
32
32
 
33
 
  if (not res || not res->length())
 
33
  if (not res)
34
34
  {
35
 
    my_error(drizzled::ER_USER_LOCKS_INVALID_NAME_LOCK, MYF(0));
 
35
    null_value= true;
36
36
    return 0;
37
37
  }
38
38
  null_value= false;
39
39
 
 
40
  if (not res->length())
 
41
    return 0;
 
42
 
40
43
  drizzled::session_id_t id= getSession().getSessionId();
41
 
  locks::return_t result;
42
 
  {
43
 
    boost::this_thread::restore_interruption dl(getSession().getThreadInterupt());
44
 
    try {
45
 
      result= user_locks::Locks::getInstance().release(Key(getSession().getSecurityContext(), res->c_str()), id);
46
 
    }
47
 
    catch(boost::thread_interrupted const& error)
48
 
    {
49
 
      my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
50
 
      return 0;
51
 
    }
52
 
  }
53
 
 
54
 
  switch (result)
55
 
  {
56
 
  default:
57
 
  case locks::SUCCESS:
58
 
    {
59
 
      user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
60
 
      assert(list);
61
 
      if (list) // Just in case we ever blow the assert
62
 
        list->erase(Key(getSession().getSecurityContext(), res->c_str()));
63
 
 
64
 
      return 1;
65
 
    }
66
 
  case locks::NOT_FOUND:
67
 
    null_value= true;
68
 
    return 0;
69
 
  case locks::NOT_OWNED_BY:
70
 
    my_error(drizzled::ER_USER_LOCKS_NOT_OWNER_OF_LOCK, MYF(0));
71
 
    return 0;
72
 
  }
 
44
  boost::tribool result= user_locks::Locks::getInstance().release(Key(getSession().getSecurityContext(), res->c_str()), id);
 
45
 
 
46
  if (result)
 
47
  {
 
48
    user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
 
49
    assert(list);
 
50
    if (list) // Just in case we ever blow the assert
 
51
      list->erase(Key(getSession().getSecurityContext(), res->c_str()));
 
52
 
 
53
    return 1;
 
54
  }
 
55
  else if (not result)
 
56
  {
 
57
    return 0;
 
58
  }
 
59
 
 
60
  null_value= true;
 
61
 
 
62
  return 0;
73
63
}
74
64
 
75
65
} /* namespace user_locks */