Commit dbfaa445 authored by hf@genie.(none)'s avatar hf@genie.(none)

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

into genie.(none):/home/hf/work/mysql-4.1.lck
parents b5bc52c7 410782fd
...@@ -475,6 +475,12 @@ Item *create_func_is_free_lock(Item* a) ...@@ -475,6 +475,12 @@ Item *create_func_is_free_lock(Item* a)
return new Item_func_is_free_lock(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) Item *create_func_quote(Item* a)
{ {
return new Item_func_quote(a); return new Item_func_quote(a);
......
...@@ -100,6 +100,7 @@ Item *create_func_version(void); ...@@ -100,6 +100,7 @@ Item *create_func_version(void);
Item *create_func_weekday(Item* a); Item *create_func_weekday(Item* a);
Item *create_load_file(Item* a); Item *create_load_file(Item* a);
Item *create_func_is_free_lock(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_quote(Item* a);
Item *create_func_geometry_from_text(Item* a); Item *create_func_geometry_from_text(Item* a);
......
...@@ -1632,8 +1632,10 @@ public: ...@@ -1632,8 +1632,10 @@ public:
bool locked; bool locked;
pthread_cond_t cond; pthread_cond_t cond;
pthread_t thread; 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)); key=(char*) my_memdup((byte*) key_arg,length,MYF(0));
pthread_cond_init(&cond,NULL); pthread_cond_init(&cond,NULL);
...@@ -1837,7 +1839,7 @@ longlong Item_func_get_lock::val_int() ...@@ -1837,7 +1839,7 @@ longlong Item_func_get_lock::val_int()
if (!(ull= ((ULL*) hash_search(&hash_user_locks,(byte*) res->ptr(), if (!(ull= ((ULL*) hash_search(&hash_user_locks,(byte*) res->ptr(),
res->length())))) res->length()))))
{ {
ull=new ULL(res->ptr(),res->length()); ull=new ULL(res->ptr(),res->length(), thd->thread_id);
if (!ull || !ull->initialized()) if (!ull || !ull->initialized())
{ {
delete ull; delete ull;
...@@ -2698,6 +2700,28 @@ longlong Item_func_is_free_lock::val_int() ...@@ -2698,6 +2700,28 @@ longlong Item_func_is_free_lock::val_int()
return 0; 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 Spatial functions
......
...@@ -1151,6 +1151,16 @@ public: ...@@ -1151,6 +1151,16 @@ public:
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;} 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 */ /* For type casts */
enum Item_cast enum Item_cast
......
...@@ -509,6 +509,7 @@ static SYMBOL sql_functions[] = { ...@@ -509,6 +509,7 @@ static SYMBOL sql_functions[] = {
{ "ISEMPTY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isempty)}, { "ISEMPTY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isempty)},
{ "ISNULL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_isnull)}, { "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_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}, { "LAST_INSERT_ID", SYM(LAST_INSERT_ID),0,0},
{ "ISSIMPLE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_issimple)}, { "ISSIMPLE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_issimple)},
{ "LCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_lcase)}, { "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