Show
Ignore:
Timestamp:
11/11/08 20:19:27 (6 years ago)
Author:
kazuho
Message:

support statement-based lock and call-based lock

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/mysql/bitmap-udf/bitmap-udf.c

    r23241 r23242  
    1515#ifndef BITMAP_DIR 
    1616# error "use -DBITMAP_DIR=dir to specify directory in which to store the bitmap" 
     17#endif 
     18 
     19#ifdef LOCK_BY_STMT 
     20# define STMT_LOCK pthread_mutex_lock(&lock_) 
     21# define STMT_UNLOCK pthread_mutex_unlock(&lock_) 
     22# define ROW_LOCK 
     23# define ROW_UNLOCK 
     24#else 
     25# define STMT_LOCK 
     26# define STMT_UNLOCK 
     27# define ROW_LOCK pthread_mutex_lock(&lock_) 
     28# define ROW_UNLOCK pthread_mutex_unlock(&lock_) 
    1729#endif 
    1830 
     
    104116  initid->maybe_null = 0; 
    105117  SETUP_ARG(0, INT_RESULT, 0); 
    106   pthread_mutex_lock(&lock_); 
     118  STMT_LOCK; 
    107119  return 0; 
    108120} 
     
    110122my_bool FUNC(_get_deinit)(UDF_INIT *initid) 
    111123{ 
    112   pthread_mutex_unlock(&lock_); 
     124  STMT_UNLOCK; 
    113125  return 0; 
    114126} 
     
    119131  size_t pos = (size_t)*(long long*)args->args[0]; 
    120132  long long v; 
     133  ROW_LOCK; 
    121134  v = map_ != NULL && pos < size_ && (map_[pos / 32] & (1 << (pos % 32))) != 0; 
     135  ROW_UNLOCK; 
    122136  return v; 
    123137} 
     
    132146  SETUP_ARG(0, INT_RESULT, 0); 
    133147  SETUP_ARG(1, INT_RESULT, 0); 
    134   pthread_mutex_lock(&lock_); 
     148  STMT_LOCK; 
    135149  return 0; 
    136150} 
     
    138152my_bool FUNC(_set_deinit)(UDF_INIT *initid) 
    139153{ 
    140   pthread_mutex_unlock(&lock_); 
     154  STMT_UNLOCK; 
    141155  return 0; 
    142156} 
     
    147161  size_t pos = (size_t)*(long long*)args->args[0]; 
    148162  int v = *(long long*)args->args[1] != 0; 
     163  ROW_LOCK; 
    149164  if (resize(pos) == 0) { 
    150165    if (v) { 
     
    156171    *error = 1; 
    157172  } 
     173  ROW_UNLOCK; 
    158174  return v; 
    159175}