Commit 4809dc74 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1

into genie.(none):/home/hf/work/mysql-4.1.lck


sql/item_create.cc:
  Auto merged
sql/item_create.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/lex.h:
  Auto merged
parents d7bccdbe 1639db08
......@@ -475,6 +475,12 @@ Item *create_func_is_free_lock(Item* a)
return new Item_func_is_free_lock(a);
}
Item *create_func_is_used_lock(Item* a)
{
current_thd->lex.uncacheable();
return new Item_func_is_used_lock(a);
}
Item *create_func_quote(Item* a)
{
return new Item_func_quote(a);
......
......@@ -100,6 +100,7 @@ Item *create_func_version(void);
Item *create_func_weekday(Item* a);
Item *create_load_file(Item* a);
Item *create_func_is_free_lock(Item* a);
Item *create_func_is_used_lock(Item* a);
Item *create_func_quote(Item* a);
Item *create_func_geometry_from_text(Item *a);
......
......@@ -1610,8 +1610,10 @@ class ULL
bool locked;
pthread_cond_t cond;
pthread_t thread;
ulong thread_id;
ULL(const char *key_arg,uint length) :key_length(length),count(1),locked(1)
ULL(const char *key_arg,uint length, ulong id)
:key_length(length),count(1),locked(1), thread_id(id)
{
key=(char*) my_memdup((byte*) key_arg,length,MYF(0));
pthread_cond_init(&cond,NULL);
......@@ -1815,7 +1817,7 @@ longlong Item_func_get_lock::val_int()
if (!(ull= ((ULL*) hash_search(&hash_user_locks,(byte*) res->ptr(),
res->length()))))
{
ull=new ULL(res->ptr(),res->length());
ull=new ULL(res->ptr(),res->length(), thd->thread_id);
if (!ull || !ull->initialized())
{
delete ull;
......@@ -2676,6 +2678,28 @@ longlong Item_func_is_free_lock::val_int()
return 0;
}
longlong Item_func_is_used_lock::val_int()
{
String *res=args[0]->val_str(&value);
THD *thd=current_thd;
ULL *ull;
null_value=1;
if (!res || !res->length())
return 0;
pthread_mutex_lock(&LOCK_user_locks);
ull= (ULL*) hash_search(&hash_user_locks,(byte*) res->ptr(),
res->length());
pthread_mutex_unlock(&LOCK_user_locks);
if (!ull || !ull->locked)
return 0;
null_value=0;
return ull->thread_id;
}
/**************************************************************************
Spatial functions
......
......@@ -1162,6 +1162,16 @@ class Item_func_is_free_lock :public Item_int_func
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
};
class Item_func_is_used_lock :public Item_int_func
{
String value;
public:
Item_func_is_used_lock(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "is_used_lock"; }
void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
};
/* For type casts */
enum Item_cast
......
......@@ -512,6 +512,7 @@ static SYMBOL sql_functions[] = {
{ "ISEMPTY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isempty)},
{ "ISNULL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isnull)},
{ "IS_FREE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_is_free_lock)},
{ "IS_USED_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_is_used_lock)},
{ "LAST_INSERT_ID", SYM(LAST_INSERT_ID),0,0},
{ "ISSIMPLE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_issimple)},
{ "LCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_lcase)},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment