~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/get_lock.cc

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    wait_time= args[1]->val_int();
37
37
  }
38
38
 
39
 
  if (not res || not res->length())
 
39
  if (not res)
40
40
  {
41
 
    my_error(drizzled::ER_USER_LOCKS_INVALID_NAME_LOCK, MYF(0));
 
41
    null_value= true;
42
42
    return 0;
43
43
  }
44
44
  null_value= false;
45
45
 
 
46
  if (not res->length())
 
47
    return 0;
 
48
 
46
49
  user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
47
50
  if (list) // To be compatible with MySQL, we will now release all other locks we might have.
48
51
    list->erase_all();
49
52
 
50
 
  bool result;
51
 
  drizzled::identifier::User::const_shared_ptr user_identifier(getSession().user());
52
 
  {
53
 
    boost::this_thread::restore_interruption dl(getSession().getThreadInterupt());
54
 
 
55
 
    try {
56
 
      result= user_locks::Locks::getInstance().lock(getSession().getSessionId(), Key(*user_identifier, res->c_str()), wait_time);
57
 
    }
58
 
    catch(boost::thread_interrupted const& error)
59
 
    {
60
 
      my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
61
 
      null_value= true;
62
 
 
63
 
      return 0;
64
 
    }
65
 
  }
 
53
  boost::tribool result= user_locks::Locks::getInstance().lock(getSession().getSessionId(), Key(getSession().getSecurityContext(), res->c_str()), wait_time);
 
54
 
 
55
  if (boost::indeterminate(result))
 
56
    null_value= true;
66
57
 
67
58
  if (result)
68
59
  {
72
63
      getSession().setProperty("user_locks", list);
73
64
    }
74
65
 
75
 
    list->insert(Key(*user_identifier, res->c_str()));
 
66
    list->insert(Key(getSession().getSecurityContext(), res->c_str()));
76
67
 
77
68
    return 1;
78
69
  }