~jaypipes/drizzle/item-class-file-reorg

« back to all changes in this revision

Viewing changes to drizzled/item/function/is_used_lock_func.cc

  • Committer: Jay Pipes
  • Date: 2008-07-30 21:08:25 UTC
  • Revision ID: jay@mysql.com-20080730210825-w17xlx7j45l2ea7e
Phase 2 work breaking out Item_func crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000-2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifdef USE_PRAGMA_IMPLEMENTATION
 
17
#pragma implementation                          // gcc: Class implementation
 
18
#endif
 
19
 
 
20
#include <drizzled/item/function/is_used_lock_func.h>
 
21
 
 
22
int64_t Item_func_is_used_lock::val_int()
 
23
{
 
24
  assert(fixed == 1);
 
25
  String *res=args[0]->val_str(&value);
 
26
  User_level_lock *ull;
 
27
 
 
28
  null_value=1;
 
29
  if (!res || !res->length())
 
30
    return 0;
 
31
  
 
32
  pthread_mutex_lock(&LOCK_user_locks);
 
33
  ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(),
 
34
                                       (size_t) res->length());
 
35
  pthread_mutex_unlock(&LOCK_user_locks);
 
36
  if (!ull || !ull->locked)
 
37
    return 0;
 
38
 
 
39
  null_value=0;
 
40
  return ull->thread_id;
 
41
}