~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/wait.cc

  • Committer: Brian Aker
  • Date: 2010-11-18 08:32:27 UTC
  • mto: (1939.1.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: brian@tangent.org-20101118083227-3evnnsgw5cwtuv7f
Add additional test for barriers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
{
32
32
  drizzled::String *res= args[0]->val_str(&value);
33
33
 
34
 
  if (not res)
35
 
  {
36
 
    null_value= true;
37
 
    return 0;
38
 
  }
39
 
  null_value= false;
40
 
 
41
 
  if (not res->length())
42
 
    return 0;
43
 
 
44
 
  Barrier::shared_ptr barrier= Barriers::getInstance().find(Key(getSession().getSecurityContext(), res->c_str()));
45
 
 
46
 
  if (barrier)
47
 
  {
48
 
    if (barrier->getOwner() == getSession().getSessionId())
 
34
  if (res and res->length())
 
35
  {
 
36
    Barrier::shared_ptr barrier= Barriers::getInstance().find(Key(getSession().getSecurityContext(), res->c_str()));
 
37
 
 
38
    if (barrier and barrier->getOwner() == getSession().getSessionId())
49
39
    {
50
40
      my_error(drizzled::ER_USER_LOCKS_CANT_WAIT_ON_OWN_BARRIER, MYF(0));
51
 
      null_value= true;
 
41
      null_value= false;
52
42
 
53
43
      return 0;
54
44
    }
55
 
 
56
 
    barrier->wait();
57
 
 
58
 
    return 1;
 
45
    else if (barrier)
 
46
    {
 
47
      if (arg_count == 2)
 
48
      {
 
49
        int64_t generation;
 
50
        generation= args[1]->val_int();
 
51
        barrier->wait(generation);
 
52
      }
 
53
      else
 
54
      {
 
55
        barrier->wait();
 
56
      }
 
57
      null_value= false;
 
58
 
 
59
      return 1;
 
60
    }
59
61
  }
60
62
 
61
63
  my_error(drizzled::ER_USER_LOCKS_UNKNOWN_BARRIER, MYF(0));
62
 
  null_value= true;
 
64
  null_value= false;
63
65
 
64
66
  return 0;
65
67
}